java - 在YouTube Activity (YouTubeBaseActivity)中显示工具栏

标签 java android youtube toolbar

这是我的xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:padding="16dp">

    <com.google.android.youtube.player.YouTubePlayerView
        android:id="@+id/youtube_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</RelativeLayout>

这是我的视频 Activity
public class VideosActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener, YouTubePlayer.PlaybackEventListener {}

如何为此 Activity 添加工具栏

最佳答案

This code only works in API level greater than 21



XML位置中的 XML放置工具栏代码
 <Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        android:theme="@style/ThemeOverlay.AppCompat.Light"
        app:popupTheme="@style/AppTheme">

    </Toolbar>

YouTubeBaseActivity中的设置工具栏
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setActionBar(toolbar);

关于java - 在YouTube Activity (YouTubeBaseActivity)中显示工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43696067/

相关文章:

java - 在 ListView 中编辑文本?

ios - 如何在You Tube上分享iPhone应用程序视频?

javascript - 在Firefox中制作插件以复制YouTube网址

支持通配符的 Java robots.txt 解析器

java - 更改android中特定页面的方向

Java 空指针异常 - 不明白为什么

android - 如何获取从 ListView 中选中的选中项目?

javascript - 如何使用 Youtube Javascript API 只播放声音?

java - 使用 Java 更改 xml-node 的节点名称

java - UML 中的特定数组类型?