【发布时间】:2013-04-10 16:08:21
【问题描述】:
我在 Fragment 中使用 YouTubePlayer(Android 版 YouTube api) 我用 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 但是有了这样的引用并不能确定是哪个引用
对他做过这件事的人?
感谢您的帮助。
问候
【问题讨论】:
-
播放器的设计使您不能在内容或控件上放置任何东西。由于您没有在布局中包含播放器,因此我只能假设布局出现在视频上方,而不是在视频下方。你能在游戏中看到你的标题吗?
-
问题解决了吗?请告诉我,我被困在这里:(
-
@Reyjhon 我没有解决这个问题。如果我找到解决方案,我会解释。如果你找到一个,我会很感激你告诉我。问候
-
你有没有找到任何解决方案,因为我也被困在这里:(
-
It
s not working for debug apk but when i generated signed apk its 工作正常。
标签: android youtube-api android-framelayout