Friday, February 22, 2013

Custom radio button and checkbox in android

Anybody know that real cool Android application must have not only excelent business logic. The one of the most important things what application must have is a nice UI.
If you want to create realy interesting application you need to create good UI. And …. hire a designer 
Below i want to tell you how to create your own CheckBoxes and RadioButtons for your Android Applications. Sorry for this sample UI design. I didn’t hire a designer :).
First look at video of that:



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"1.0" encoding="utf-8"?>
 android:orientation="vertical" android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 
  android:layout_width="wrap_content"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:id="@+id/textView1"
  android:layout_height="wrap_content"
  android:text="Custom Radio Button "/>
 
  android:id="@+id/radioGroup1"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
  
   android:text="Cool"
   android:button="@drawable/my_ratingbar"
   android:layout_height="wrap_content"
   android:id="@+id/radio0"
   android:layout_width="134dp"/>
  
   android:text="Sexy"
   android:button="@drawable/my_ratingbar"
   android:layout_height="wrap_content"
   android:id="@+id/radio1"
   android:checked="true"
   android:layout_width="wrap_content"/>
  
   android:text="Both"
   android:button="@drawable/my_ratingbar"
   android:layout_height="wrap_content"
   android:id="@+id/radio2"
   android:layout_width="wrap_content"/>
 
 
  android:layout_width="wrap_content"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_marginTop="20dp"
  android:id="@+id/textView1"
  android:layout_height="wrap_content"
  android:text="Custom Check Box "/>
 
  android:text="CheckBox1"
  android:id="@+id/checkBox1"
  android:checked="true"
  android:button="@drawable/my_ratingbar"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"/>
 
  android:text="CheckBox2"
  android:id="@+id/checkBox2"
  android:button="@drawable/my_ratingbar"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"/>
 
  android:layout_width="wrap_content"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_marginTop="20dp"
  android:id="@+id/textView1"
  android:layout_height="wrap_content"




my_ratingbar.xml

?
1
2
3
4
5
"1.0" encoding="utf-8"?>
 "true" android:drawable="@drawable/red_holo" />
 "false" android:drawable="@drawable/red_full" />

red_holo


red_full


No comments:

Post a Comment