如何将进度条置于布局顶部

How to bring progress bar in top of layout

我在我的相对布局中包含了一个进度条,但它在布局后面运行。有什么办法可以把它放在前面显示它在页面加载时显示。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:background="@color/pageBackgroundColor"
    android:gravity="center"
    tools:context="co.sd.app.CheckoutActivity">

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:visibility="visible" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/relativeLayout"
        android:layout_marginLeft="@dimen/page_marging_left"
        android:layout_marginRight="@dimen/page_marging_right">

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/service_detail_cv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/shedule_apt_cv"
            android:layout_marginBottom="@dimen/dim_10sp"
            android:layout_marginTop="@dimen/dim_10sp"
            android:textColor="@color/darkGrey" />

    </RelativeLayout>

</RelativeLayout>

不知道为什么会这样显示

使用此代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:background="@color/pageBackgroundColor"
    android:gravity="center"
    tools:context="co.sd.app.CheckoutActivity">



    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/relativeLayout"
        android:layout_marginLeft="@dimen/page_marging_left"
        android:layout_marginRight="@dimen/page_marging_right">

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/service_detail_cv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/shedule_apt_cv"
            android:layout_marginBottom="@dimen/dim_10sp"
            android:layout_marginTop="@dimen/dim_10sp"
            android:textColor="@color/darkGrey" />

    </RelativeLayout>

<ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:visibility="visible" />

</RelativeLayout>

希望这对您有所帮助..