我在片段中使用YouTubePlayer(
Android API的YouTube api)
我通过YouTube播放器向LinearLayout充气:
@H_301_29@解决方法
我通过YouTube播放器向LinearLayout充气:
fragmentManager = getActivity().getSupportFragmentManager(); fragmentTransaction = fragmentManager.beginTransaction(); player = new YouTubePlayerSupportFragment(); fragmentTransaction.add(R.id.youTubePlayerContainer,player); fragmentTransaction.commit();
…哪里youTubePlayerContainer是膨胀的LinearLayout
YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by android.widget.FrameLayout@4110d1f8. YouTubePlayerView is completely covered,with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 484,top: 100,right: 100,bottom: 170..
这是我的XML:
(其中没有FrameLayout)
<LinearLayout android:id="@+id/curtain" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/withApi" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <LinearLayout android:id="@+id/youTubePlayerContainer" android:layout_width="match_parent" android:layout_height="0dp" android:layout_gravity="center" android:layout_margin="30dp" android:layout_weight="1" android:orientation="vertical" > </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="3dp" android:background="@color/trans_popUp" android:padding="3dp" > <TextView android:id="@+id/textYouTubeVisor" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Title..." android:textColor="@color/white" /> </LinearLayout> </LinearLayout>
我试着改变利润,没有成功.
我正在阅读官方文件,但没有成功
表示导致问题的FrameLayout是:android.widget.FrameLayout @ 4110d1f8
但是有了这样一个参考,并不能确定哪一个是指的
对他这样做的人呢?
我感谢任何帮助.
问候
你能解决这个问题吗?
我今天遇到同样的问题,对我而言,日志中的错误是:
W/YouTubeAndroidPlayerAPI﹕ YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is not contained inside its ancestor com.google.android.youtube.player.YouTubePlayerView{42686bc8 V.E..... ........ 0,0-1200,675 #7f0a00a0 app:id/video_player}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: -10,top: -10,right: -10,bottom: -10 (these should all be positive).
我通过删除布局中的YouTubePlayerView中的填充来修复此问题.所以我的布局看起来像这样:
<com.google.android.youtube.player.YouTubePlayerView android:id="@+id/video_player" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#000" />