check boxes are not aligned properly



I want to make some thing like this


enter image description here


Trying following code but in view layouts are not properly aligned can someone help me out with this.



<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical" >

<TextView
android:id="@+id/txtServices"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Services "
android:textSize="22dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<CheckBox
android:id="@+id/chkService1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Dine In" />

<CheckBox
android:id="@+id/chkService2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Take Away" />

<CheckBox
android:id="@+id/chkService3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Home Delivery" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<CheckBox
android:id="@+id/chkService4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="BYO" />

<CheckBox
android:id="@+id/chkService5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Bar" />

<CheckBox
android:id="@+id/chkService6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Gluten Free" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<CheckBox
android:id="@+id/chkService7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Vegan" />

<CheckBox
android:id="@+id/chkService8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Vegiterian" />

<CheckBox
android:id="@+id/chkService9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Organic" />
</LinearLayout>
</LinearLayout>
</LinearLayout>


Try to align all check boxes properly to get view as shown. I have tried with managing vertical layouts but not helping.


No comments:

Post a Comment