【问题标题】:Show Toolbar in Youtube Activity (YouTubeBaseActivity)在 Youtube 活动中显示工具栏 (YouTubeBaseActivity)
【发布时间】:2017-04-29 13:08:08
【问题描述】:

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

如何为此活动添加工具栏

【问题讨论】:

    标签: java android youtube toolbar


    【解决方案1】:

    此代码仅适用于大于 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>
    

    在你的 YouTubeBaseActivity 设置工具栏

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setActionBar(toolbar);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-19
      • 2016-03-02
      相关资源
      最近更新 更多