首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >前棒棒糖设备上类似阴影的android浮动动作按钮

前棒棒糖设备上类似阴影的android浮动动作按钮
EN

Stack Overflow用户
提问于 2014-12-31 03:57:31
回答 1查看 4.2K关注 0票数 0

我正试着在前棒棒糖设备上做一个浮动的动作按钮。我已经设法做了一个像样的按钮,但它看起来不好没有任何阴影。

这是circle.xml文件

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>

        <layer-list>

            <item>

                <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">

                    <solid android:color="#ffffffff" />

                    <size android:width="40dp" android:height="40dp" />
                </shape>
            </item>

        </layer-list>
    </item>
</selector>

和imagebutton

代码语言:javascript
复制
 <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/circle"
        android:src="@drawable/ic_search"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:padding="10dp"
        android:layout_margin="16dp"
        />

如何添加阴影,使其看起来像材料设计浮动动作按钮?

EN

回答 1

Stack Overflow用户

发布于 2015-09-26 11:38:29

请将其用作circle.xml。

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item android:top="8px">
    <layer-list>
        <item>
            <shape android:shape="oval">
                <solid android:color="#08000000"/>
                <padding
                    android:bottom="3px"
                    android:left="3px"
                    android:right="3px"
                    android:top="3px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#09000000"/>
                <padding
                    android:bottom="2px"
                    android:left="2px"
                    android:right="2px"
                    android:top="2px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#10000000"/>
                <padding
                    android:bottom="2px"
                    android:left="2px"
                    android:right="2px"
                    android:top="2px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#11000000"/>
                <padding
                    android:bottom="1px"
                    android:left="1px"
                    android:right="1px"
                    android:top="1px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#12000000"/>
                <padding
                    android:bottom="1px"
                    android:left="1px"
                    android:right="1px"
                    android:top="1px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#13000000"/>
                <padding
                    android:bottom="1px"
                    android:left="1px"
                    android:right="1px"
                    android:top="1px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#14000000"/>
                <padding
                    android:bottom="1px"
                    android:left="1px"
                    android:right="1px"
                    android:top="1px"
                    />
            </shape>
        </item>
        <item>
            <shape android:shape="oval">
                <solid android:color="#15000000"/>
                <padding
                    android:bottom="1px"
                    android:left="1px"
                    android:right="1px"
                    android:top="1px"
                    />
            </shape>
        </item>

    </layer-list>
</item>

<item>
    <shape android:shape="oval">
        <solid android:color="@color/ColorPrimary" />
    </shape>
</item>

</layer-list>

来源:http://www.android4devs.com/2015/03/how-to-make-floating-action-button-fab.html

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27711709

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档