【问题标题】:Progress bar shadow only on filled part进度条阴影仅在填充部分
【发布时间】:2017-03-16 17:09:00
【问题描述】:

在android中实现一个进度条,试图只在填充部分的底部获得阴影,如下所示:

API 级别是 KitKat 及以上,但我不介意仅适用于 LOLLIPOP 及以上的解决方案。 海拔似乎不起作用,卡片视图也不起作用。 有什么建议吗?

【问题讨论】:

    标签: android progress-bar shadow android-elevation


    【解决方案1】:

    创建以下 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-14
      • 1970-01-01
      • 1970-01-01
      • 2014-03-27
      • 2011-11-13
      相关资源
      最近更新 更多