如何将文本方向更改为android中开关的右侧滑动?

Sad*_*ary 1 android text switch-statement

在默认模式下,Switch位于ON/OFF状态左侧的文本。我想将此文本的方向更改为右侧幻灯片。我怎样才能做到这一点?

我已经尝试过此xml代码但无法正常工作:

<Switch
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/switch1"
android:layout_gravity:"right"
android:layout_margin="@dimen/abc_dropdownitem_text_padding_right"/>
Run Code Online (Sandbox Code Playgroud)

Mur*_*ain 5

AFAIK 那是不可行的,您可以尝试以下操作

<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>
Run Code Online (Sandbox Code Playgroud)