[英]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.