在Android中,可以使用`android:gravity="end"`属性将Switch右对齐。您可以在布局文件中的Switch元素上添加此属性。示例如下:
```xml
android:id="@+id/switchButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="end" /> ``` 另外,您还可以使用相对布局(RelativeLayout)来实现右对齐。示例如下: ```xml android:layout_width="match_parent" android:layout_height="wrap_content"> android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Switch" android:layout_alignParentStart="true" android:layout_centerVertical="true" /> android:id="@+id/switchButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_centerVertical="true" /> ``` 上述代码中,通过将Switch的`android:layout_alignParentEnd`属性设置为true,将Switch元素与其父容器的右侧对齐。