Skip to main content

Posts

Showing posts with the label check Box

Check Box : Material Design Tips

From google material design documentation.
Checkboxes allow the user to select multiple options from a set.
If you have multiple options appearing in a list, you can preserve space by using checkboxes instead of on/off switches.
If you have a single option, avoid using a checkbox and use an on/off switch instead. How to add? I. In your build.gradle add latest appcompat library. dependencies { compile 'com.android.support:appcompat-v7:X.X.X'// where X.X.X version} II. Make your activity extend android.support.v7.app.AppCompatActivity. publicclassMainActivityextendsAppCompatActivity{...} III. Declare your CheckBox inside any layout.xml file <CheckBoxandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:checked="true"android:text="Check Box"/> How to style?
I. Declare custom style in your styles.xml

Android Basic Tutorial CheckBox Radio Button

XML File ( Layout File )
[ CheckBox - 1 | TextView -2 | RadioButton - 3 ]
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical" >
    <CheckBox         android:id="@+id/cbxBox1"         android:layout_width="20dp"         android:layout_height="20dp"         android:checked="false" />
    <TextView         android:id="@+id/txtCheckBox"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:text="CheckBox: Not checked" />
    <RadioGroup         android:id="@+id/rgGroup1"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:orientation="vert…

Android Basic Tutorial 3 - Check Box Example

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"     android:paddingLeft="@dimen/activity_horizontal_margin"     android:paddingRight="@dimen/activity_horizontal_margin"     android:paddingTop="@dimen/activity_vertical_margin"     tools:context=".MainActivity" >
    <TextView         android:id="@+id/textView1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignParentLeft="true"         android:layout_alignParentRight="true"         android:layout_alignParentTop="true"         android:text="@string/chk_txt"         android:textAppearance="?android:attr/te…