在开关按钮上对齐文本-Android Studio

时间:2018-08-28 20:18:24

标签: android

我正在开发我的第一个应用程序。

我想知道是否可以在“切换”按钮顶部而不是向右或向左对齐文本?

目前,我可以将文字设置在切换按钮的右侧或左侧。

我知道简单的方法就是添加文本视图。但这对我来说真的很有趣:

switch button

1 个答案:

答案 0 :(得分:0)

您应在textview上方添加switch,并保留切换文本empty/null

例如

   <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>
相关问题