Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Switch text to right side in android?

Android default Switch have text and then Switch on/off. I'm Expecting Switch on/off and then text. Don't use another widgets like TextView. How can i set Switch right side text.

like image 960
Murali Ganesan Avatar asked Sep 26 '13 08:09

Murali Ganesan


People also ask

What is Switch in Android Studio?

android.widget.Switch. A Switch is a two-state toggle widget. Users can drag the switch "thumb" back and forth to select either of two options or simply tap the switch to toggle between options. The text property controls the text of the switch label. The textOn and textOff properties control the text of the thumb.


1 Answers

enter image description here

Wrap it in another layout with no text value and add a textview. see my code:

    <LinearLayout         android:layout_width="match_parent"         android:orientation="horizontal"         android:paddingTop="10dp"         android:paddingBottom="10dp"         android:layout_height="wrap_content">             <Switch                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:id="@+id/reminder" />             <TextView                 android:layout_width="wrap_content"                 android:text="Meeting Reminders"                 android:layout_height="wrap_content" />     </LinearLayout> 
like image 79
keithics Avatar answered Sep 21 '22 22:09

keithics