Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.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
Android 基于当前主题定制颜色搜索栏_Android_Android Theme_Android Seekbar - Fatal编程技术网

Android 基于当前主题定制颜色搜索栏

Android 基于当前主题定制颜色搜索栏,android,android-theme,android-seekbar,Android,Android Theme,Android Seekbar,我正在尝试创建一个自定义的SeekBar,它的height=“1dp”&width=“match\u parent”和基于当前选定主题的任何颜色 我必须做这件事。但它使用已经准备好的图像 而不是图像,我只想使用动态颜色的1dp线 在styled_seekbar_progress.xml中,我写道(这是使用layerlist来判断在progress和secondary progress中使用哪个drawable的xml): 我相信,我不能在android:drawable=“@drawable

我正在尝试创建一个自定义的
SeekBar
,它的
height=“1dp”
&
width=“match\u parent”
和基于当前选定主题的任何颜色

我必须做这件事。但它使用已经准备好的图像

而不是图像,我只想使用动态颜色的1dp线

styled_seekbar_progress.xml中,我写道(这是使用
layerlist
来判断在
progress
secondary progress
中使用哪个drawable的xml):

我相信,我不能在
android:drawable=“@drawable/img\u seekbar\u played\u 1dp”
中使用(代替图像)。安卓正在等待一个图像

那么,如何使用我的
来形成一个seekbar呢


谢谢

您想使用什么颜色?颜色应该是动态的,并根据当前主题在运行时决定。但是为了简单起见,现在假设一种单一的颜色,比如蓝色。所以使用shape drawable,你可以指定它的实体color@pskink但是如何定义2种颜色(用于进度和辅助进度)。我尝试使用两个形状元素的图层列表,但它只使用一种颜色,而不使用第二种颜色。如果您能提供默认xml文件作为答案,我们将不胜感激,最重要的是“clip”标记
<item
    android:id="@+android:id/SecondaryProgress"
    android:drawable="@drawable/img_seekbar_played_1dp">
</item>
<item
    android:id="@+android:id/progress"
    android:drawable="@drawable/img_seekbar_unplayed_1dp">
</item>
<View xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="1.5dp"
    android:background="?seekbar_line_played_color"
/>
<View xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="1.5dp"
    android:background="?seekbar_line_unplayed_color"
/>
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/styled_seekbar_progress.xml from drawable resource ID #0x7f020002
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag View
at.android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)