相对布局中心的进度条

Yaw*_*war 1 android alignment relativelayout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?android:attr/actionBarSize"
android:background="@drawable/stalker_background"
android:focusableInTouchMode="true" >


<ProgressBar 
    android:id="@+id/pb"
    android:layout_height="75dp"
    android:layout_width="75dp"
    android:layout_gravity="center"
    android:indeterminate="true"      
    />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<ScrollView 
    android:id="@+id/svProfile"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

<android.support.v4.view.ViewPager
                android:id="@+id/VPSlider"
                android:layout_width="match_parent"
                android:layout_height="175dp"
            />


            <android.support.v4.app.FragmentTabHost
                android:id="@android:id/tabhost"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >

                    <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" />

                    <FrameLayout
                    android:id="@android:id/tabcontent"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

                </LinearLayout>

                </android.support.v4.app.FragmentTabHost>       

</LinearLayout>
</ScrollView>
</LinearLayout>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

进度条出现在屏幕的角落,如何将其对齐在屏幕中央.我有相对布局,我在屏幕上显示一些东西之后删除了这个进度条,这就是为什么我需要在其他控件之上.

Har*_*ran 15

试试这个..

添加android:layout_centerInParent="true"到您的,ProgressBar因为您的父布局是RelativeLayout

<ProgressBar 
    android:id="@+id/pb"
    android:layout_height="75dp"
    android:layout_width="75dp"
    android:layout_gravity="center"
    android:indeterminate="true"      
    android:layout_centerInParent="true"
    />
Run Code Online (Sandbox Code Playgroud)