Vertical alignment of an Android SwitchCompat?

1.2k views Asked by At

In Android, is it possible to vertical align a SwitchCompat , that is, to put the text above the switch instead of on the left of the switch ?

2

There are 2 answers

1
Shabeer Ali On BEST ANSWER

are you looking for something like this ..?

enter image description here

try this

<LinearLayout
    android:id="@+id/switchLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:padding="5dp"
    android:orientation="vertical">
    <TextView
        android:id="@+id/switchTxt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#000000"
        android:text="Switch"/>
    <Switch
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:rotation="90"
        android:layout_margin="10dp"
        android:layout_marginLeft="3dp"
        android:id="@+id/switch1" />
</LinearLayout>
0
EE66 On

It doesnt look like it. U can wrap a TextView and SwitchCompat with a LinearLayout to get the result that u want.