I want to create a button that looks exactly like a CheckBox (same
size, same button face color, etc.), but instead of a checkmark, has a
square with a configurable color on it. My solution was to subclass a
View, set the background resource to a shape drawable which mimics the
CheckBox background and then override onDraw() to put the colored
rectangle on top. All this worked great in the emulator, but when I
tested it on a device, I quickly learned that devices have their own
stylized controls and my control looked out of place.

I looked at the built-in Android resources and found that
android.R.drawable.button_default_small might work nicely as the
background resource. However, the button face is not centered within
the 9-patch image, probably because of the drop-shadow so it makes it
hard to position my colored rectangle. Also, I'm not sure how to find
the dimensions of a CheckBox to size my control --
android.R.dimen.default_checkbox_size seems like a good place, but it
doesn't exist :-).

What do others do to make custom controls that integrate well with any
device's UI?

Thanks,
Jeff

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to