android-switch

How can I style an Android Switch?

老子叫甜甜 提交于 2019-11-26 11:00:57
The switch widget introduced in API 14 is styled by default with holo theme. I want to style it slightly different, changing its colors and shape a bit for branding reasons. How does one go about this? I know it must be possible, as ive seen the difference between default ICS and Samsung's touchwiz theme I assume I'll need some state drawables, and I've seen a few styles in http://developer.android.com/reference/android/R.styleable.html with Switch_thumb and Switch_track that look like what I might be after. I just don't know how to go about using them. I'm using ActionbarSherlock if that

How to change the size of a Switch Widget

北战南征 提交于 2019-11-26 05:27:02
问题 In Ice Cream Sandwich a Switch Widget was introduced that displays an On Off Slider. I added the Switch like this: <Switch android:layout_width=\"fill_parent\" android:layout_height=\"48dp\" android:textStyle=\"bold\" android:thumb=\"@drawable/switch_thumb_selector\" android:track=\"@drawable/switch_bg_selector\" /> The track and thumb drawables are nine patch images that should scale to all possible sizes. I hoped that the Switch would scale to the maximum size inside the given bounds, but

How to custom switch button?

可紊 提交于 2019-11-26 04:07:32
问题 I am looking to Custom The Switch Button to becoming as following : How to achieve this ? 回答1: you can use the following code to change color and text : <org.jraf.android.backport.switchwidget.Switch android:id="@+id/th" android:layout_width="match_parent" android:layout_height="wrap_content" app:thumb="@drawable/apptheme_switch_inner_holo_light" app:track="@drawable/apptheme_switch_track_holo_light" app:textOn="@string/switch_yes" app:textOff="@string/switch_no" android:textColor="#000000" /