I am having a main on/off switch for my service at the top. I would like this switch to be big and visible.
If I change the textOn attribute to be longer, it is somewhat doing what I want, but I want that to happen with a shorter textOn string length.
I tried changing thumbTextPadding and switchMinWidth and both of them didn't increase the size of the switch.
How do I change the size of SwitchCompat object?
Currently my switch object is as below :
<android.support.v7.widget.SwitchCompat
android:id="@+id/start_service"
style="@style/SwitchStyleCompat"
android:text="@string/start_service_title"
app:showText="true" />
<style name="SwitchStyleCompat">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginTop">@dimen/heading_top_margin</item>
<item name="android:layout_marginBottom">@dimen/heading_bottom_margin</item>
<item name="track">@drawable/abc_switch_track_mtrl_alpha</item>
<item name="switchTextAppearance">@style/SwitchTextAppearance</item>
<item name="android:thumb">@drawable/abc_switch_thumb_material</item>
<item name="android:textOn">@string/switch_on</item>
<item name="android:textOff">@string/switch_off</item>
<item name="android:layout_alignParentLeft">true</item>
<item name="android:layout_alignParentTop">true</item>
<item name="android:clickable">true</item>
<item name="android:checked">false</item>
<item name="android:focusable">true</item>
<item name="android:textAppearance">@style/SwitchTextFont</item>
<item name="android:textColor">@color/text_heading_color</item>
<item name="android:gravity">center_vertical|start</item>
<item name="android:thumbTextPadding">25dp</item>
<item name="android:switchMinWidth">56dp</item>
</style>
You can increase the track length by using the material attribute app:switchMinWidth="70dp"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With