Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Holo Everywhere时无法更改android开关样式_Android_Android Layout_Android Styles - Fatal编程技术网

使用Holo Everywhere时无法更改android开关样式

使用Holo Everywhere时无法更改android开关样式,android,android-layout,android-styles,Android,Android Layout,Android Styles,我在更改项目中切换视图的样式时遇到问题,无法找出我做错了什么或遗漏了什么。。。我的项目在任何地方都使用holo 我无法更改文字、拇指或音轨。我已经尝试直接从xml中应用android:thumb和android:track可绘制内容,但没有任何变化。甚至安卓:textOff和安卓:textOn都没有任何效果 我找到了一篇关于如何定制android Switch视图样式的好文章,浏览了所有代码,但没有找到任何我做错的地方: 真的不知道还有什么可以尝试 以下是xml代码: <Swit

我在更改项目中切换视图的样式时遇到问题,无法找出我做错了什么或遗漏了什么。。。我的项目在任何地方都使用holo

我无法更改文字、拇指或音轨。我已经尝试直接从xml中应用android:thumb和android:track可绘制内容,但没有任何变化。甚至安卓:textOff和安卓:textOn都没有任何效果

我找到了一篇关于如何定制android Switch视图样式的好文章,浏览了所有代码,但没有找到任何我做错的地方:

真的不知道还有什么可以尝试

以下是xml代码:

    <Switch
        android:id="@+id/home_availability_switch"
        style="@style/MySwitch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:enabled="true"
        android:focusable="true"
        android:textOff="Free"
        android:textOn="Busy" />

风格如下:

<style name="MySwitch" parent="@style/Holo.Switch.Light">
    <item name="android:thumb">@drawable/selector_availability_switch_thumb</item>
    <item name="android:track">@drawable/selector_availability_switch_background</item>
</style>

@可牵引/选择器\可用性\开关\拇指
@可拖动/选择器\u可用性\u开关\u背景
这是拇指选择器 (这些是默认的系统绘图。我尝试了不同的绘图):


这是轨道选择器 (这些是默认的系统绘图。我尝试了不同的绘图):


我也找到了这篇文章,并按照说明进行操作,但运气不好


其他人在使用Holo Everywhere时有过类似的经历吗?

您需要这样定义开关。需要完整的包名才能工作

<org.holoeverywhere.widget.Switch
    android:id="@+id/lockSwitch"
    style="?switchStyleOld"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TestSwitch" />


希望这有帮助。

您忘记为“style”属性添加名称空间。您不需要为style添加名称空间。就是这样!谢谢整个上午都在搞这个。如上所述,在holoeverywhere包中引用Switch view类时,可设置样式的属性的前缀更改为app:。所以app:textOn、app:thumb等…app之所以可用,是因为我在父布局中声明了xmlns:app=“”。@AswinRajendiran真的吗?奇怪的还有其他不需要它的属性吗?
<item android:drawable="@drawable/switch_bg_disabled_holo_dark" android:state_enabled="false"/>
<item android:drawable="@drawable/switch_bg_focused_holo_dark" android:state_focused="true"/>
<item android:drawable="@drawable/switch_bg_holo_dark"/>
<org.holoeverywhere.widget.Switch
    android:id="@+id/lockSwitch"
    style="?switchStyleOld"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TestSwitch" />