【问题标题】:Widget Switch only shows text and not the buttonWidget Switch 仅显示文本而不显示按钮
【发布时间】:2015-11-17 21:47:16
【问题描述】:

我有一个不显示为开关的开关小部件。相反,我只看到文字。

代码如下:

<Switch
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:id="@+id/switch1"
    android:layout_below="@id/divider5"
    android:textOff="OFF"
    android:textOn="ON"/>

我能做些什么来解决它?

【问题讨论】:

  • 尝试使用android:background改变Switch控件的背景

标签: android android-widget android-switch


【解决方案1】:

我遇到了同样的问题。您应该设置一些可绘制资源来拇指和跟踪开关。 例如:

<Switch
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:id="@+id/switch1"
    android:layout_below="@id/divider5"
    android:textOff="OFF"
    android:textOn="ON"
    android:track="@drawable/your_track"
    android:thumb="@drawable/your_thumb" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-24
    • 2013-10-30
    • 2021-07-30
    • 2018-09-26
    • 1970-01-01
    • 1970-01-01
    • 2014-10-26
    • 2020-12-23
    相关资源
    最近更新 更多