Reputation: 43
How to set 4 edittexts side by side to each other in LinearLayout, is it possible to do that? Please suggest me
Upvotes: 0
Views: 71
Reputation: 3402
Try this
<LinearLayout
android:layout_width="0dp"
android:orientation="horizontal"
android:layout_weightSum="4" >
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
</LinearLayout>
Upvotes: 1
Reputation: 40
On LinearLayout
, you should have:
-> orientation=horizontal
-> layout_weight=1
-> layout_height=0dp
On EditText
, you should have:
-> layout_weight=0.25 (4*0.25 = 1)
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<EditText
android:layout_width="match_parent"
android:layout_weight="0.25"
android:layout_height="wrap_content" />
<EditText
android:layout_width="match_parent"
android:layout_weight="0.25"
android:layout_height="wrap_content" />
<EditText
android:layout_width="match_parent"
android:layout_weight="0.25"
android:layout_height="wrap_content" />
<EditText
android:layout_width="match_parent"
android:layout_weight="0.25"
android:layout_height="wrap_content" />
</LinearLayout>
Upvotes: 1