我正在为进度条使用自定义布局,该进度条由小条组成,具体取决于步数。布局如下所示:
我想创建一个项目,该项目显示一个黑色的条形和一个白色的条形,看起来像进度之间的空格。
现在,我知道可以用两个单独的项目来创建它。但是我把这个项目作为进度条的进度。例如:
<!-- Define the progress properties like start color, end color etc -->
<item android:id="@android:id/progress">
<clip>
<shape 1>
<shape 2>
</clip>
</item>
现在,如何创建一个内部可以包含两个形状的自定义项目?
答案 0 :(得分:0)
progress.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="3dp"
android:height="2dp"
android:drawable="@drawable/text_field"
android:start="@dimen/dimen_5dp" />
<item
android:width="3dp"
android:drawable="@drawable/text_field"
android:end="@dimen/dimen_5dp" />
</layer-list>
text_field.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true">
<shape>
<gradient
android:endColor="@color/white"
android:startColor="@color/white"/>
<corners android:radius="5dp"/>
</shape>
</item>
</selector>