Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Youtube活动中显示工具栏(Youtube活动)_Java_Android_Youtube_Toolbar - Fatal编程技术网

Java 在Youtube活动中显示工具栏(Youtube活动)

Java 在Youtube活动中显示工具栏(Youtube活动),java,android,youtube,toolbar,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_w

这是我的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>
如何为此活动添加工具栏

public class VideosActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener, YouTubePlayer.PlaybackEventListener {}
此代码仅适用于大于21的API级别

在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>
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setActionBar(toolbar);