【问题标题】:Vertical alignment of an Android SwitchCompat?Android SwitchCompat的垂直对齐?
【发布时间】:2015-06-20 20:00:50
【问题描述】:

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

【问题讨论】:

    标签: android android-appcompat switchcompat


    【解决方案1】:

    你在寻找这样的东西吗..?

    试试这个

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

    【讨论】:

    • 我不需要旋转开关,但下次我会记住的。谢谢。
    【解决方案2】:

    看起来不像。 你可以用 LinearLayout 包装 TextView 和 SwitchCompat 以获得你想要的结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-02
      • 2013-04-17
      • 2014-12-05
      • 1970-01-01
      • 1970-01-01
      • 2011-06-13
      相关资源
      最近更新 更多