how to change text direction to the right slide of switch in android?

前端 未结 3 1751
生来不讨喜
生来不讨喜 2021-01-23 12:56

In default mode , text of a Switch sit on the left side of ON/OFF states. I want to change direction of this text to the right slide. How can i do

相关标签:
3条回答
  • 2021-01-23 13:16

    You can use this:

    android:layoutDirection="rtl"

    0 讨论(0)
  • 2021-01-23 13:30

    AFAIK thats not doable, you can try the following

    <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
    
            <Switch
                android:id="@+id/switch_gprs"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="false"
                android:paddingBottom="15dp"
                />
    
            <TextView
    
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="false"
                android:paddingBottom="15dp"
                android:layout_toRightOf="@+id/switch_gprs"
                android:text="sometext"/>
    
    
        </RelativeLayout>
    
    0 讨论(0)
  • 2021-01-23 13:38

    Or you can do :

    <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
    
            <Switch
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="My Switch"/>
    
    </LinearLayout>
    
    0 讨论(0)
提交回复
热议问题