Android 片段上的YouTube API-错误-YouTube视频播放因未经授权覆盖在播放器顶部而停止
下面是我的活动布局XMLAndroid 片段上的YouTube API-错误-YouTube视频播放因未经授权覆盖在播放器顶部而停止,android,youtube-api,Android,Youtube Api,下面是我的活动布局XML <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="0dp"
tools:context="com.hfad.bitsandpizzas.MainActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_main" />
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_workout_view_pager"
android:layout_width="wrap_content"
android:background="@drawable/customborder"
android:layout_height="wrap_content">
</android.support.v4.view.ViewPager>
</LinearLayout>
据我所知,这个问题与活动/片段的布局有关,你知道如何解决这个问题吗。你不能有任何关于youtube播放器片段的视图。您膨胀的youtube片段实例上的任何视图覆盖都会导致视频在指定时间后停止播放。好的,但是您能否指定需要修改哪些内容来修复此问题,我认为您的
框架布局
可能覆盖了YouTube标签
。还将线性布局的高度和宽度设置为匹配父项
。问题似乎在于日志中所述的查看页面
,ViewPager的右侧边缘似乎有问题:它是负数(也在ViewPager和YouTubePlayerView的日志中说明)。我从未在ViewPager中使用YouTubePlayer,但我认为问题在于,当视图未完全显示给用户时(即隐藏在屏幕边界之外),播放会以某种方式开始。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:background="@drawable/customborder"
android:layout_height="wrap_content">
<-- youtube player will be displayed here -->
<FrameLayout
android:id="@+id/youtube_layout"
android:layout_width="220dp"
android:layout_height="220dp"
android:layout_margin="10dp"
android:background="@drawable/customborder"
android:layout_centerHorizontal="false"
/>
</LinearLayout>
W/YouTubeAndroidPlayerAPI: YouTube video playback stopped due to unauthorized overlay on top of player.
The YouTubePlayerView is not contained inside its ancestor android.support.v4.view.ViewPager{33c5dbf VFED..... ......ID 0,112-720,1184 #7f08001a app:id/activity_workout_view_pager}.
The distances between the ancestor's edges and that of the YouTubePlayerView is: left: 740, top: 60, right: -460, bottom: 572 (these should all be positive).