将路径颜色从黄色更改为白色

将路径颜色从黄色更改为白色

本文介绍了搜索栏,将路径颜色从黄色更改为白色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个问题:

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

1) how do I change the color of the seek bar (path) from yellow (the default color) to white. What I mean to say is, while I slide the thumb , it turns the line traversed from grey to yellow. I want track/line to either remain grey or white..Basically I want just the thumb to move with no color change in the seek bar.

2)如何将搜索栏的拇指从矩形更改为圆形/球形/圆形.

2)How to change the thumb of seekbar from rectangle to circle/sphere/round shape.

任何指针将不胜感激.

推荐答案

我想为刚接触系统的人完成上面的答案,

I want to complete the answer from above for the people who are new to the system,

缺少的 xmls( background_fill , progress_fill 和 progress 可能看起来像渐变红色

the missing xmls ( background_fill , progress_fill and progress could look like that for a gradient red

<?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>

background_fill.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#FF555555"
        android:centerColor="#FF555555"
        android:endColor="#FF555555"
        android:angle="90" />

    <corners android:radius="5px" />

    <stroke
        android:width="2dp"
        android:color="#50999999" />

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

progress_fill.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#FF470000"
        android:centerColor="#FFB80000"
        android:endColor="#FFFF4400"
        android:angle="180" />

    <corners android:radius="5px" />

    <stroke
            android:width="2dp"
            android:color="#50999999" />

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

我没有完成android:thumb的实现,所以拇指还是原来的那个

i did not complete the implementing for android:thumb, so the thumb will be still the original one

因此,我们只需从定义搜索栏的布局 xml 中再次删除这一行

Therefore we just have to delete this line again from our layout xml where we define the seekbar

android:thumb="@drawable/thumb"

祝你好运!!!

这篇关于搜索栏,将路径颜色从黄色更改为白色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 18:35