I have a problem with my RelativeLayout.
I placed 6 Views next to each other and it works.
The problem i have are the EditTexts. When i set their width to wrap_content they are too small.
When i set them to match_parent they take the whole width (they are overlaying the other Views) instead of adjusting to the edges of the Views next to them.
So my question is how can i make them fit without giving them static widths?
Here is my code:
<RelativeLayout
android:id="@+id/relativelayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tv1"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="text 1" />
<EditText
android:id="@+id/et1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/tv1"
android:singleLine="true" />
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/et1"
android:text="text 2" />
<EditText
android:id="@+id/et2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/tv2"
android:singleLine="true" />
<TextView
android:id="@+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/et2"
android:text="text 3" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/tv3" />
</RelativeLayout>
With a Relative Layout you need either a satisfaying wrapcontent or static dimensions.
If I understand well, you want the edit text to fill what is left of the screen’s width.
You would have to use a LinearLayout and the
android:layout_weightproperty – you can find an example here: