android - 从文本左侧的切换按钮绘制拇指和跟踪器

标签 android widget

在开关按钮上设置文本时的默认结果是右侧的缩略图/轨道

+-------------+----------+
|             |          |
|  Lorem Ispu | on / off |
|             |          |
+-------------+----------+

要知道有没有什么方法可以让thump/tacker 被放置在文本的左侧而无需编写自定义小部件:

+-----------+-------------+
|           |             |
|  on / off | Lorem Ipsum |
|           |             |
+-----------+-------------+

谢谢:)

最佳答案

我找到的唯一方法是将 Switch 和 TextView 包裹在 LinearLayout 中:

    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <android.support.v7.widget.SwitchCompat
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:checked="true"
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Your text:"/>
</LinearLayout>

希望对您有所帮助。 想法与此处提到的相同:How to show android checkbox at right side?我只是颠倒了顺序。

关于android - 从文本左侧的切换按钮绘制拇指和跟踪器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27736948/

相关文章:

Flutter:将手势阻止到小部件下方

android - 检测应用程序是否被手动关闭

Android 自定义可跨越字符串的组合跨度

Android Studio Android 模拟器无法启动。

Android WidgetProvider复制

java - 图表/小部件/仪表/UI

c# - Windows 窗体列表框中的平滑滚动

android - 当我使用自己的广告单元 ID 时,我的 AdMob 插页式广告代码出现错误

android - 信标接收器控制

android - 应用程序小部件 setImageViewUri 不更新图像