[英]Remove the top and bottom padding in a SeekBar
因為指定的選項
android:background="@color/your_colour"
將無法使用,因為您有兩種顏色,一種用於頂部,另一種用於底部。
可行的解決方案是通過使用以下圖層列表:
轉到您的drawable
文件夾,創建一個back_ground_seek_bar.xml
的文件,並在其中添加以下代碼:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:bottom="10dp">
<shape android:shape="rectangle" >
<size android:height="10dp" />
<solid android:color="@colour/your_top_color" />
</shape>
</item>
<item android:top="10dp">
<shape android:shape="rectangle" >
<size android:height="10dp" />
<solid android:color="@color/your_bottom_color" />
</shape>
</item>
</layer-list>
粘貼時用自己的顏色替換顏色。 請記住,我們將top和height設置為10,但是因為我們希望SeekBar
具有顏色,所以我們必須將seekbar的高度設置為該值的兩倍,因此它應該為兩倍,即20dp。 因此,我們應該將搜索欄的新高度添加為20dp,並將背景設置為我們定義的xml,如下所示。 轉到您的SeekBar並將其粘貼:
android:layout_height="20dp"
android:background="@drawable/back_ground_seek_bar"
為了進行自定義,您還可以在drawable/back_ground_seek_bar.xml
更改height
和其他值,但應始終為兩次。 SeekBar
目標中設置的給定高度是將其平均划分。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.