Customizing a spinner in android. -2
ain.xml which defines the main layout.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
| <? xml version = "1.0" encoding = "utf-8" ?> android:orientation = "vertical" android:layout_width = "fill_parent" android:layout_height = "fill_parent" android:background = "@drawable/bkg" > < TextView android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:text = "@string/hello" /> < Spinner android:id = "@+id/spinner" android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:drawSelectorOnTop = "true" android:prompt = "@string/prompt" /> </ LinearLayout > |
Now the layout for each row in the spinner.
row.xml
row.xml
01
02
03
04
05
06
07
08
09
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
| <? xml version = "1.0" encoding = "utf-8" ?> android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:orientation = "vertical" android:padding = "3dip" > < ImageView android:id = "@+id/image" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:src = "@drawable/icon" /> < TextView android:layout_toRightOf = "@+id/image" android:padding = "3dip" android:layout_marginTop = "2dip" android:textColor = "@drawable/red" android:textStyle = "bold" android:id = "@+id/company" android:text = "CoderzHeaven" android:layout_marginLeft = "5dip" android:layout_width = "wrap_content" android:layout_height = "wrap_content" /> < TextView android:layout_toRightOf = "@+id/image" android:padding = "2dip" android:textColor = "@drawable/darkgrey" android:layout_marginLeft = "5dip" android:id = "@+id/sub" android:layout_below = "@+id/company" android:text = "Heaven of all working codes" android:layout_width = "wrap_content" android:layout_height = "wrap_content" /> </ RelativeLayout > |
Now the strings.xml.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
| <? xml version = "1.0" encoding = "utf-8" ?> <? xml version = "1.0" encoding = "utf-8" ?> < resources > < string name = "hello" >CustomSpinner Demo from CoderzHeaven!</ string > < string name = "prompt" >Select your Favourite</ string > < string name = "app_name" >CustomSpinner Demo</ string > < drawable name = "white" >#ffffff</ drawable > < drawable name = "black" >#000000</ drawable > < drawable name = "green" >#347C2C</ drawable > < drawable name = "pink" >#FF00FF</ drawable > < drawable name = "violet" >#a020f0</ drawable > < drawable name = "grey" >#778899</ drawable > < drawable name = "red" >#C11B17</ drawable > < drawable name = "yellow" >#FFFF8C</ drawable > < drawable name = "PowderBlue" >#b0e0e6</ drawable > < drawable name = "brown" >#2F1700</ drawable > < drawable name = "Hotpink" >#7D2252</ drawable > < string name = "select_Category" >Select Category</ string > < drawable name = "darkgrey" >#606060</ drawable > </ resources > |
Please click the +1 button on top to share it with your friends and leave your valuable comments also.
No comments:
Post a Comment