0

VideoView の上にボタンを表示または非表示にしようとすると問題が発生します。簡単にするために、このような xml ファイルを用意しました。実際のファイルにはもっと多くのボタンがあります。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

<VideoView
    android:id="@+id/videoEnter"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:scaleType="fitXY" />

<Button
    android:id="@+id/play"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Play" />

</RelativeLayout>

基本的に、ビデオを再生するときはボタンを に設定しView.INVISIBLE、ビデオが終了しonCompletionたらボタンを に設定しますView.Visible。問題は、ボタンをクリックできることですが、VideoView の背後にあり、表示されません。FrameLayoutでこれを機能させることができましたが、RelativeLayoutでしか機能しないように見える画面に合わせてビデオビューを引き伸ばす必要があります。このすべてを RelativeLayout で機能させる方法はありますか?

私も試してみ.bringToFront()ましたが、成功しませんでした。

助けてくれてありがとう

4

1 に答える 1

0

これは、VideoViewにfill_parentを使用したためだと思いました。また、あなたは以下のすべてを真実として使用しました:

android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"

つまり、アクティビティは画面全体を拡大することです。次のようにします。線形レイアウトを使用して、ビューに重みを割り当てます。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
<VideoView
    android:layout_weight="0.9"
    android:id="@+id/videoEnter"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
/>
<Button
    android:layout_weight="0.1"
    android:id="@+id/play"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Play" />
</LinearLayout>

これを試してみましたが、下部にボタンが表示され、画面の残りの部分にVideoViewが表示されます。

于 2013-02-24T20:41:00.300 に答える