u2gilles
u2gilles

Reputation: 7393

Vertical alignment of an Android SwitchCompat?

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 ?

Upvotes: 1

Views: 1303

Answers (2)

Shabeer Ali
Shabeer Ali

Reputation: 1033

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>

Upvotes: 2

EE66
EE66

Reputation: 4661

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

Upvotes: 0

Related Questions