首页 > 解决方案 > FrameLayout覆盖RelativeLayout中的ProgressBar

问题描述

在 aRelativeLayout中,我使用ProgressBarand FrameLayoutFrameLayout我用不同的片段进行初始化。

但是我看不到ProgressBar,因为FrameLayout覆盖它。我不想要这个。

我想把它放在ProgressBar上面FrameLayout。(它们应该重叠但ProgressBar应该在上面)。

我怎样才能做到这一点?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <ProgressBar
        android:id="@+id/mainProgressBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         />
    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_marginTop="25px"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
         />
</RelativeLayout>

标签: androidandroid-layoutandroid-fragments

解决方案


相对布局从下到上显示视图(意味着底部子视图将出现在顶部)。要解决您的问题,您只需在框架布局下方放置进度条:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
        <FrameLayout
            android:id="@+id/frameLayout"
            android:layout_marginTop="25px"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />
        <ProgressBar
            android:id="@+id/mainProgressBar"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             />

</RelativeLayout>

推荐阅读