Android 搜索栏,将路径颜色从黄色更改为白色

Android 搜索栏,将路径颜色从黄色更改为白色,android,android-emulator,Android,Android Emulator,我有两个问题: 1) 如何将搜索栏(路径)的颜色从黄色(默认颜色)更改为白色。我的意思是,当我滑动拇指时,它会将穿过的线从灰色变为黄色。我希望轨迹/线条保持灰色或白色。基本上,我只希望拇指移动,搜索栏中没有颜色变化 (二) 如何将seekbar的拇指从矩形更改为圆形/球体/圆形 任何指点都将不胜感激 您应该设置SeekBar XML属性: <SeekBar .... android:progressDrawable="@drawable/progress"

我有两个问题:

1) 如何将搜索栏(路径)的颜色从黄色(默认颜色)更改为白色。我的意思是,当我滑动拇指时,它会将穿过的线从灰色变为黄色。我希望轨迹/线条保持灰色或白色。基本上,我只希望拇指移动,搜索栏中没有颜色变化

(二) 如何将seekbar的拇指从矩形更改为圆形/球体/圆形


任何指点都将不胜感激

您应该设置SeekBar XML属性:

<SeekBar 
            ....
    android:progressDrawable="@drawable/progress"
    android:thumb="@drawable/thumb"
            ....
/>

其中的进展是这样的:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background" 
    android:drawable="@drawable/background_fill" />

<item android:id="@android:id/progress">
    <clip android:drawable="@drawable/progress_fill" />
</item>
</layer-list> 

拇指是

<?xml version="1.0" encoding="utf-8"?>    
<selector xmlns:android="http://schemas.android.com/apk/res/android">
   <item android:drawable="@drawable/thumb_fill" />
</selector>

我想为系统新手填写上面的答案

缺少的XML(背景填充、进度填充和进度)可能与渐变红色的XML类似

progress.xml
祝你好运!!!

由于默认情况下
SeekBar
使用
colorAccent
,您可以使用自定义颜色创建一个新样式,如
colorAccent
,然后使用
主题
属性将其应用于SeekBar

<SeekBar>
    .
    .
    android:theme="@style/MySeekBarTheme"
    .
</SeekBar>

.
.
android:theme=“@style/MySeekBarTheme”
.
在@style中:

 <style name="MySeekBarTheme" parent="Widget.AppCompat.SeekBar" >
        <item name="colorAccent">#ffff00</item>
 </style>

#ffff00

您只需从API级别21添加色调即可

将以下属性添加到seekbar元素:

android:progressTint=“@android:color/white” android:thumbTint=“@android:color/white”

最终结果:

<SeekBar
    android:id="@+id/is"
    android:layout_width="match_parent"
    android:max="100"
    android:progressTint="@android:color/white"
    android:thumbTint="@android:color/white"/>

只需更改样式的强调色即可

<style name="TickMarkSeekBar" parent="Theme.KefTheme">
        <item name="tickMark">@drawable/tickmark</item>
        <item name="thumbTint">@android:color/white</item>
        <item name="colorAccent">@android:color/white</item>
    </style>

@可画/记号
@android:彩色/白色
@android:彩色/白色

1.创建可绘制的XML: 命名为:progress\u drawable


2.将其分配给Seekbar

            <SeekBar
                    android:id="@+id/slider_1"
                    android:progressDrawable="@drawable/progress_drawable"
                    android:layout_width="180dp"
                    android:layout_height="32dp"
                    android:layout_gravity="center"
                    android:rotation="270" />


Hello,我试图在drawable文件夹中创建上述.xml文件。但我遇到了以下错误:未找到与给定名称匹配的资源(位于'drawable'处,值为'@drawable/background\u fill')。未找到与给定名称匹配的资源(位于'drawable'处,值为'@drawable/progress\u fill'))。这些都是您必须自己创建的绘图:您可以使用9.png(或其他可绘图资源-和)根据自己的意愿装饰您的seekbar。这个答案非常正确:)用户357349必须接受它。谢谢。。。您节省了我的很多精力:)您好,您的示例非常好,但我无法为seekbar添加自定义拇指。你能帮我演示一下如何给你的例子加上拇指吗?谢谢
 <style name="MySeekBarTheme" parent="Widget.AppCompat.SeekBar" >
        <item name="colorAccent">#ffff00</item>
 </style>
seekBar.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
seekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
<SeekBar
    android:id="@+id/is"
    android:layout_width="match_parent"
    android:max="100"
    android:progressTint="@android:color/white"
    android:thumbTint="@android:color/white"/>
<style name="TickMarkSeekBar" parent="Theme.KefTheme">
        <item name="tickMark">@drawable/tickmark</item>
        <item name="thumbTint">@android:color/white</item>
        <item name="colorAccent">@android:color/white</item>
    </style>
<?xml version="1.0" encoding="UTF-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="line">

<stroke android:width="1dp" android:color="#fff"/>

</shape>
            <SeekBar
                    android:id="@+id/slider_1"
                    android:progressDrawable="@drawable/progress_drawable"
                    android:layout_width="180dp"
                    android:layout_height="32dp"
                    android:layout_gravity="center"
                    android:rotation="270" />