android - Android SwitchCompat 的垂直对齐方式?

标签 android android-appcompat switchcompat

在 Android 中,是否可以垂直对齐 SwitchCompat ,即将文本放在开关上方而不是开关左侧?

最佳答案

你在找这样的东西吗?

enter image description here

试试这个

<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>

关于android - Android SwitchCompat 的垂直对齐方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30951392/

相关文章:

Android对象持久化: Ektorp and CouchDB

Android - AppCompatEditText 主题未在 fragment 内部应用

java - RecyclerView 适配器上的 SwitchCompat

android - SwitchCompat 在 4.3 及以下版本上缺少可绘制的拇指

android - 在 Android 中添加提醒

android - 如何在Android上绘制条形图

Android 的某些 EditText 字段不响应长按(API 30+ with layout_width 0dp)

android - 如何更改SwitchCompat的字体系列?

java - SQLite 更新后获取旧值

android - AppCompatTextView autoSizeTextType 不起作用