android - Unable to make two views to occupy the screen equally -


i using following code create table layout containing text view , spinner.

<tablelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:stretchcolumns="1">      <tablerow>          <textview             android:id="@+id/lbllistheader"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_marginbottom="20dp"             android:layout_marginleft="20dp"             android:layout_weight="1"             android:layout_marginright="20dp"             android:layout_margintop="20dp"             android:text="form"             android:singleline="true"             android:textcolor="#000" />         <spinner             android:id="@+id/spinner1"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_weight="1"             android:background="@android:drawable/btn_dropdown"             android:spinnermode="dropdown"             android:entries="@array/action"/>      </tablerow> </tablelayout> 

the problem width of both text view , spinner not equal. size of spinner becomes small when size of text view big. how can sort out issue ?

change width of both of them 0 instead of wrap_content.

android:layout_width="0dp" 

when you're using weight , width @ same time, width attribute override weight.


Comments