Java 在Youtube活动中显示工具栏(Youtube活动)
这是我的xml: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
<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);