我想像使用 textviews 一样将两个开关居中,但我尝试了所有可能的选项但没有成功。
这是代码的简短版本:
<LinearLayout [...]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="NOTIFICATIONS" />
<TextView [...] />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Switch
android:id="@+id/swnotif"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1" />
<Switch [...] />
</LinearLayout>
</LinearLayout>