【发布时间】:2015-03-25 17:21:22
【问题描述】:
我有一个带有 YouTubePlayerSupportFragment 和浮动操作按钮的 Activity。在视频开始之前浮动按钮是可以点击的,但是在视频初始化之后,我不能再点击浮动按钮了。我想让它在视频开始后可点击。 我知道 View 不能覆盖 YouTubePlayer,但在这种情况下,按钮不会覆盖 YouTubePlayer。
这是我的活动 xml,其中包含 YouTubePlayerFragment 和浮动按钮:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_youtube_player_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="hanappaula.br.youtubedownloader.activities.YouTubePlayerActivity">
<fragment
android:id="@+id/activity_youtube_fragment"
android:name="com.google.android.youtube.player.YouTubePlayerSupportFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/activity_youtube_floating_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="@drawable/ic_content_add"
fab:fab_colorNormal="#2196F3"
fab:fab_colorPressed="#448AFF"
fab:fab_colorRipple="#9E9E9E" />
</RelativeLayout>
【问题讨论】:
-
您确定按钮没有覆盖片段吗?这是您的
RelativeLayout的第二个孩子,所以它有可能会排在首位。在片段视图中添加android:layout_above="@+id/activity_youtube_floating_button"怎么样? -
我不确定,但由于片段仅占据活动的 1/3,并且其中的视频正在播放,我几乎可以确定按钮没有覆盖片段.我尝试了你所说的,但我仍然无法使按钮可点击。
标签: android youtube android-youtube-api