Eliran Liri Elgozi
Eliran Liri Elgozi

Reputation: 27

Align text over switch button - android studio

I'm working on my first app.

And I was wondering is there an option to to align a text on top of the switch button instead of right or left?

At the moment I can set the text to the right side or the left side of the switch button.

I know the easy way is just to add a text view. But this is really interesting to me:

switch button

Upvotes: 1

Views: 2385

Answers (1)

Krishna Sharma
Krishna Sharma

Reputation: 2877

You should add textview above to switch and keep switch text empty/null.

For example

   <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/switchTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Add 3 Beeps" />

        <Switch
            android:id="@+id/switchButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/switchTitle"
            android:text="@null" />
    </RelativeLayout>

Upvotes: 1

Related Questions