[英]Android seekbar thumb drawable not displayed correctly
I created a custom seekbar thumb, it looks very good on android studio previews, but when running the app on my device, it looks wrong ! 我创建了一个自定义的seekbar拇指,在android studio预览中看起来非常好,但是在我的设备上运行该应用时,它看起来不对!
what it should look like 它应该是什么样
what it actually look like on my device 设备上的实际外观
my seekbar_thumb.xml code 我的seekbar_thumb.xml代码
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:height="35dp" android:width="35dp" >
<shape android:shape="oval">
<solid android:color="#fff" />
</shape>
</item>
<item android:gravity="center" android:height="15dp" android:width="15dp">
<shape android:shape="oval">
<solid android:color="@color/colorPrimary" />
</shape>
</item>
my seekbar code 我的seekbar代码
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/seekBar"
android:max="100"
android:progress="50"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:thumb="@drawable/seekbar_thumb"
android:progressDrawable="@drawable/progress_bar_background"
android:layout_marginBottom="@dimen/seekbar_margin_bottom"
android:layout_marginRight="@dimen/seekbar_margin_rt"
android:layout_marginLeft="@dimen/seekbar_margin_lt"
android:thumbOffset="0dp"/>
Try this seekbar_thumb.xml in drawable folder 在可绘制文件夹中尝试这个seekbar_thumb.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="#00f"/>
<size
android:width="15dp"
android:height="15dp"/>
</shape>
</item>
<item>
<shape android:shape="oval">
<stroke android:color="@android:color/transparent"
android:width="5dp"/>
<solid android:color="#f00"/>
<size
android:width="10dp"
android:height="10dp"/>
</shape>
</item>
</layer-list>
And activity_main.xml 和activity_main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="40dp">
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/seekBar"
android:max="100"
android:progress="50"
android:thumb="@drawable/seekbar_thumb" />
</RelativeLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.