Android RelativeLayout how to align two views horizontally -


this code:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:paddingleft="16dp"     android:paddingright="16dp" >      <textview         android:id="@+id/tv_id"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparenttop="true"         android:text="your text" />      <spinner         android:id="@+id/s_country"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_below="@id/tv_id"         android:layout_toleftof="@+id/city"         android:entries="@array/country_spinner_values" />      <spinner         android:id="@+id/city"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentright="true"         android:layout_below="@+id/tv_id"         android:entries="@array/city_spinner_values" />  </relativelayout> 

and result: enter image description here

as see spinner in left takes more space spinner in right. how can make each 1 of them takes same space, in other words, same width both of them?

note: not use linearlayout

what this?

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:paddingleft="16dp"     android:paddingright="16dp" >      <textview         android:id="@+id/tv_id"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparenttop="true"         android:text="belongs to:" />      <spinner         android:id="@+id/s_country"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_below="@id/tv_id"         android:layout_toleftof="@+id/view"         android:entries="@array/country_spinner_values" />      <view         android:id="@+id/view"         android:layout_width="0dp"         android:layout_height="1dp"         android:layout_below="@+id/tv_id"         android:layout_centerhorizontal="true" />      <spinner         android:id="@+id/city"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentright="true"         android:layout_below="@+id/tv_id"         android:layout_torightof="@+id/view"         android:entries="@array/city_spinner_values" />  </relativelayout> 

enter image description here


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -