android - How to center two sibling TextView in RelativeLayout? -


i have layout below. need b , c centered below a. simplify view need one relativelayout if possible.

<relativelayout     android:layout_gravity="center_horizontal"     android:layout_width="wrap_content"     android:layout_height="60dp">     <textview         android:id="@+id/a"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="test 1"         android:paddingtop="3dp" />      <textview         android:id="@+id/b"         android:layout_below="@id/a"         android:paddingright="5dp"         android:textcolor="#000"         android:text="test 2"         android:layout_width="wrap_content"         android:layout_height="wrap_content" />      <textview         android:id="@+id/c"         android:layout_torightof="@id/b"         android:layout_below="@id/a"         android:textcolor="#f00"         android:text="test 3"         android:layout_width="wrap_content"         android:layout_height="wrap_content" />  </relativelayout> 

update ended below, not best, because b , c not below a.

<relativelayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_gravity="center_horizontal"     android:layout_centerhorizontal="true"     android:layout_width="wrap_content"     android:layout_height="60dp">      <textview         android:id="@+id/a"         android:layout_centerhorizontal="true"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="test 1"         android:paddingtop="3dp" />      <textview         android:layout_alignparentbottom="true"         android:paddingright="5dp"         android:textcolor="#000"         android:text="test 2"         android:id="@+id/b"         android:layout_width="wrap_content"         android:layout_height="wrap_content" />      <textview         android:layout_alignparentbottom="true"         android:layout_torightof="@id/b"         android:textcolor="#f00"         android:id="@+id/c"         android:text="test 3"         android:layout_width="wrap_content"         android:layout_height="wrap_content" />  </relativelayout> 

you have wrap them in layout, this:

<relativelayout     android:layout_gravity="center_horizontal"     android:layout_width="wrap_content"     android:layout_height="60dp">     <textview         android:id="@+id/a"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="test 1"         android:paddingtop="3dp" />      <linearlayout         layout_centerhorizontal="true"         android:layout_below="@id/a"         android:orientation="horizontal"         android:layout_width="wrap_content"         android:layout_height="wrap_content">          <textview             android:id="@+id/b"             android:paddingright="5dp"             android:textcolor="#000"             android:text="test 2"             android:layout_width="wrap_content"             android:layout_height="wrap_content" />          <textview             android:id="@+id/c"             android:textcolor="#f00"             android:text="test 3"             android:layout_width="wrap_content"             android:layout_height="wrap_content" />      </linearlayout>  </relativelayout> 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -