这是我的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/