如果我在所有进度行中设置 draw "progress drawable",SeekBar
我会得到 bgdraw。如何设置从开始到拇指位置的绘制?
问问题
9406 次
3 回答
8
你可以这样使用:
在drawable文件夹中创建一个自定义文件....
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background" >
<shape>
<gradient
android:startColor="#00000000"
android:centerColor="#00000000"
android:centerX="1"
android:endColor="#00000000"
android:angle="0"
/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress" >
<clip android:clipOrientation="horizontal" android:gravity="left" >
<shape>
<gradient
android:startColor="@color/blue"
android:centerColor="@color/blue"
android:centerX="0.75"
android:endColor="@color/blue"
android:angle="0"
/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress" >
<clip android:clipOrientation="horizontal" android:gravity="left" >
<shape>
<gradient
android:startColor="@color/blue"
android:centerColor="@color/blue"
android:centerX="0.75"
android:endColor="@color/blue"
android:angle="0"
/>
</shape>
</clip>
</item>
然后在您的 xml 文件中设置此自定义文件:
<SeekBar
android:id="@+id/skProgress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@android:color/white"
android:gravity="center|center_vertical"
android:progressDrawable="@drawable/progress_Ever" // here whatever name your custom file in drawable...set to here
/>
于 2013-09-02T06:46:42.987 回答
4
在你的 xml
<SeekBar
android:id="@+id/skProgress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@android:color/white"
android:gravity="center|center_vertical"
android:progressDrawable="@drawable/progress_drawable"
/>
progress_drawable.xml
将此xml放在Drawable文件夹中
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background" >
<shape>
<gradient
android:startColor="#00000000"
android:centerColor="#00000000"
android:centerX="1"
android:endColor="#00000000"
android:angle="0"
/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress" >
<clip android:clipOrientation="horizontal" android:gravity="left" >
<shape>
<gradient
android:startColor="@color/blue"
android:centerColor="@color/blue"
android:centerX="0.75"
android:endColor="@color/blue"
android:angle="0"
/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress" >
<clip android:clipOrientation="horizontal" android:gravity="left" >
<shape>
<gradient
android:startColor="@color/blue"
android:centerColor="@color/blue"
android:centerX="0.75"
android:endColor="@color/blue"
android:angle="0"
/>
</shape>
</clip>
</item>
</layer-list>
于 2013-09-02T06:27:11.557 回答
1
在你的 xml 中放这个
<SeekBar
.....
android:background="@null"
android:splitTrack="false"
android:progressDrawable="@drawable/progress_drawable"
/>
并在您的 seek_bar_progress drawable 中将背景部分留空,但将渐变部分与剪辑标签放在一起。
<item android:id="@android:id/secondaryProgress" >
<clip android:clipOrientation="horizontal" android:gravity="left" >
<shape>
<gradient
android:startColor="@color/blue"
android:centerColor="@color/blue"
android:centerX="0.75"
android:endColor="@color/blue"
android:angle="0"
/>
</shape>
</clip>
</item>
于 2016-06-03T09:57:29.090 回答