Android Layout with CheckButtons and Button at bottom
Hey Guys, this is my first blog on Android. Hope, you will like it.
In this blog i am going to show how to create a simple layout on Android in which lots of checkboxes are there and a button is present at the bottom.Many people have doubts in this as how to create a button at bottom of page in LinearLayout in Android.So, lets do this..
1 ) First of all create Android Application Project in eclipse.
2) Go to res-> layout->activity_main.xml and copy paste the below code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Choose Category"
android:textColor="#ffffff"
android:textSize="25sp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<CheckBox
android:id="@+id/all"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15sp"
android:background="#C0C0C0"
android:checked="true"
android:text="Select All"
android:textColor="#ffffff"
android:textSize="22sp" />
<CheckBox
android:id="@+id/clothing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Clothing"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/electronics"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Electronics"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/footwear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Footwear"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/health"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Health Care"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/hardware"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Hardware"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/sports"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Sports"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/book"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Book"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/medicine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Medicine"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/kids"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Kids"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/kitchen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Hardware"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/grocery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Grocery and Vegetable"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/food"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Order Food"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/lens"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Lens Shop"
android:textColor="#ffffff" />
</LinearLayout>
</ScrollView>
<Button
android:id="@+id/done"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center"
android:background="#95B9C7"
android:text="Done" />
</LinearLayout>
Finally you will get the layout as shown in the figure..
Thanks....Comment if you have any doubts. I would love to answer that.
In this blog i am going to show how to create a simple layout on Android in which lots of checkboxes are there and a button is present at the bottom.Many people have doubts in this as how to create a button at bottom of page in LinearLayout in Android.So, lets do this..
1 ) First of all create Android Application Project in eclipse.
2) Go to res-> layout->activity_main.xml and copy paste the below code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Choose Category"
android:textColor="#ffffff"
android:textSize="25sp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<CheckBox
android:id="@+id/all"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15sp"
android:background="#C0C0C0"
android:checked="true"
android:text="Select All"
android:textColor="#ffffff"
android:textSize="22sp" />
<CheckBox
android:id="@+id/clothing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Clothing"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/electronics"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Electronics"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/footwear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Footwear"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/health"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Health Care"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/hardware"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Hardware"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/sports"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Sports"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/book"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Book"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/medicine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Medicine"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/kids"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Kids"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/kitchen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Hardware"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/grocery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Grocery and Vegetable"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/food"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Order Food"
android:textColor="#ffffff" />
<CheckBox
android:id="@+id/lens"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Lens Shop"
android:textColor="#ffffff" />
</LinearLayout>
</ScrollView>
<Button
android:id="@+id/done"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center"
android:background="#95B9C7"
android:text="Done" />
</LinearLayout>
Finally you will get the layout as shown in the figure..
Thanks....Comment if you have any doubts. I would love to answer that.
Comments
Post a Comment