2011-12-12 61 views
0

我的XML代码:Android的布局priotity

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

    <RelativeLayout 
     android:id="@+id/relativeLayout2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:visibility="invisible"> 


     <ImageButton 
      android:id="@+id/video_playback_pause" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"/> 


     <SeekBar 
      android:id="@+id/seekbar_video" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" android:layout_below="@id/video_playback_pause" android:clickable=""/> 

    </RelativeLayout> 

    <VideoView 
     android:id="@+id/videoView1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_centerInParent="true" /> 

</RelativeLayout> 

现在磨片的RelativeLayout和VideoView覆盖。 显示VideoView,并隐藏RelativeLayout。 如何使VideoView顶部的RelativeLayout?

另一个问题是为什么seekbar没有点击?

我发现布局的优先级是通过建立顺序来决定的吗? 但是seekbar的问题仍然没有解决。

回答

1

尝试......

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/RelativeLayout1" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<RelativeLayout 
    android:id="@+id/relativeLayout2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" > 


    <ImageButton 
     android:id="@+id/video_playback_pause" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 


    <SeekBar 
     android:id="@+id/seekbar_video" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" android:layout_below="@+id/video_playback_pause" android:clickable="true"/> 

</RelativeLayout> 

<VideoView 
    android:id="@+id/videoView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true" /> 

</LinearLayout> 

编辑:

可以使用公开程度属性如下

android:visibility="invisible" // invisible- just invisible the controls not the space 
           //gone - removes the allocated space too 
           //visible- shows the control 

在运行时也可以更改

mylayout.setVisibilty(View.GONE)... 
1

问题的第一部分的答案。
的android:layout_width = “FILL_PARENT” 机器人:layout_height = “FILL_PARENT” 机器人:layout_centerInParent = “真”> 内的RelativeLayout的可见性设置为invisible.Remove它。

您已经为seekbar提供了android:clickable =“”。可能是这就是为什么它不工作。 删除并尝试。

希望这会帮助你。

+0

我只想在videoview触摸时显示relativeLayout2。所以我最初看不见。 – brian

+0

秒,它仍然没有工作。 – brian

1

当谈到哟你可能会有这样的答案:设置

android:clickable="true" 

并且在你的java代码中,试着放一个Event Listener。对于事件监听器,http://developer.android.com/guide/topics/ui/ui-events.html

说到布局,可以尝试使用线性布局,然后在其中嵌套相对布局。你可能需要改变你的xml。