Android布局优先级

发布于 2024-12-20 14:51:22 字数 1437 浏览 5 评论 0原文

我的 xml 代码:

<?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 隐藏。 如何将RelativeLayout放在VideoView的顶部?

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

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

My xml code:

<?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>

Now whe RelativeLayout and VideoView override.
the VideoView is show, and the RelativeLayout is hidden.
How to make the RelativeLayout on the top of VideoView?

Another problem is why the seekbar did not click?

I find that the priority of layout is decide by establish order?
But the problem of seekbar is still not resolve.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

宛菡 2024-12-27 14:51:22

试试这个...

 <?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)...

Try this...

 <?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>

EDIT:

You can use the visibilty property as below

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

At run time also you can change

mylayout.setVisibilty(View.GONE)...
慢慢从新开始 2024-12-27 14:51:22

当谈到你的搜索栏时,这可能是可能的答案:设置

android:clickable="true" 

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

当涉及到布局时,您可以尝试使用线性布局,然后在其中嵌套相对布局。您可能需要稍微更改一下 xml。

When it comes to your seekbar, this could be the possible answer: Set

android:clickable="true" 

and in your java code, try putting an Event Listener. For Event Listeners, http://developer.android.com/guide/topics/ui/ui-events.html

When it comes to your layout, you can try using a Linear Layout and then nest a Relative Layout inside it. You might have to change your xml a bit.

剩余の解释 2024-12-27 14:51:22

回答问题的第一部分。

安卓:layout_width =“fill_parent”
安卓:layout_height =“fill_parent”
android:layout_centerInParent="true">

内部relativeLayout的可见性设置为不可见。将其删除。

您已为搜索栏提供了android:clickable=""。可能这就是它不起作用的原因。
删除它并尝试。

希望这会对您有所帮助。

Answer for the first part of question.

android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true">

The inner relativeLayout's visibility is set to invisible.Remove it.

You have provided android:clickable="" for seekbar. May be thats why its not working.
Remove that and try.

Hope this will help you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文