带内边距的 Android 进度条 [英] Android progress bar with padding
本文介绍了带内边距的 Android 进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想让我的进度条看起来像这样:
I want to make my progress bar looks something like that:
我不想使用图像,所以我尝试用形状来制作:
I dont want to use images, so I have tried to make this with the shapes:
<item android:id="@android:id/background">
<shape>
<corners android:radius="50dp" />
<gradient
android:angle="270"
android:centerColor="#2a2723"
android:centerY="0.75"
android:endColor="#2a2723"
android:startColor="#2a2723" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="50dp" />
<gradient
android:angle="270"
android:centerColor="#16e61c"
android:centerY="0.75"
android:endColor="#9dfd6e"
android:startColor="#16e61c" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="50dp" />
<gradient
android:angle="270"
android:endColor="#9dfd6e"
android:startColor="#16e61c" />
</shape>
</clip>
</item>
但是我不能为绿线设置填充(我试图在任何可能的地方设置它),而且我也不能做这样的圆角(看起来像 corners android:radius
不工作).请帮帮我
But I cant set padding for the green line (Ive tried to set its everywhere where it was possible), and also I can't make such round corners (looks like corners android:radius
isn't working). Please help me
推荐答案
<?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>
<solid android:color="#222" />
<corners android:radius="10dp" />
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<layer-list>
<item>
<color android:color="#00000000" />
</item>
<item
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp">
<shape>
<solid android:color="#00FF00" />
<corners android:radius="10dp" />
</shape>
</item>
</layer-list>
</clip>
</item>
</layer-list>
这篇关于带内边距的 Android 进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文