在相对布局中查看中心

use*_*801 2 android view relativelayout

我有一个relativelayout包含一个progressbar和一个Loading textview..我需要progressbar和文本视图锥体在相对布局的中心.但它更多的是向右而不是在中心.下面是我的代码..

<RelativeLayout 
                android:layout_width="fill_parent"
                android:layout_height="26dp" 
                android:layout_gravity="bottom"
             android:background="@drawable/border">
                        <ProgressBar
                        style="?android:attr/progressBarStyleSmall"
                        android:id="@+id/progressBar"
                        android:layout_width="20dp"
                        android:layout_height="20dp"
                        android:layout_centerInParent="true"
                        android:layout_centerHorizontal="true" />


              <TextView 
                        android:id="@+id/TextViewProgress"
                        android:text="Loading"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="16dp"
                        android:layout_toRightOf="@+id/progressBar"
                        />
Run Code Online (Sandbox Code Playgroud)

Ren*_*ith 5

添加android:gravity="center"RelativeLayout

<RelativeLayout 
   android:layout_width="fill_parent"
   android:layout_height="26dp" 
   android:layout_gravity="bottom"
   android:background="@drawable/border"
   android:gravity="center">

   <ProgressBar
       style="?android:attr/progressBarStyleSmall"
       android:id="@+id/progressBar"
       android:layout_width="20dp"
       android:layout_height="20dp"
       android:layout_centerInParent="true"
       android:layout_centerHorizontal="true" />

   <TextView 
       android:id="@+id/TextViewProgress"
       android:text="Loading"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:textSize="16dp"
       android:layout_toRightOf="@+id/progressBar" />
Run Code Online (Sandbox Code Playgroud)