在 android 中实现一个进度条,试图只在填充部分的底部获得一个投影,如下所示:
API 级别为 KitKat 及以上,但我不介意仅适用于 LOLLIPOP 及以上的解决方案。 海拔似乎不起作用,卡片 View 也不起作用。 有什么建议吗?
最佳答案
创建以下 xml 形状并将其放置为进度条背景。
** xml 中的 10dp 假定 progressBar 的高度为 20dp,并且您希望阴影正好是它的一半。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<layer-list>
<item android:bottom="10dp">
<shape android:shape="rectangle">
<solid android:color="@color/orange" />
</shape>
</item>
</layer-list>
</item>
<item android:id="@android:id/progress">
<clip>
<layer-list>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/green" />
</shape>
</item>
<item android:top="10dp">
<shape android:shape="rectangle">
<gradient
android:angle="90"
android:endColor="@color/black"
android:startColor="@color/white" />
</shape>
</item>
</layer-list>
</clip>
</item>
</layer-list>
关于android - 进度条阴影仅在填充部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40396026/