問題描述
我有兩個問題:
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"
祝你好運!!!
這篇關于搜索欄,將路徑顏色從黃色更改為白色的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!