波纹效果framelayout圆形按钮

时间:2017-03-09 19:56:50

标签: android button effect ripple

我的布局中有这种显示方式:

<FrameLayout
            android:layout_width="110dp"
            android:layout_height="110dp"
            android:layout_marginBottom="5dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/roundbutton"
            android:backgroundTint="@color/beatiful_yellow"
            android:foreground="?attr/selectableItemBackground"
            android:clickable="true">

            <Button
                android:id="@+id/downloadButton"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:background="@null"
                android:drawableLeft="@drawable/ic_file_download_black_60px"
                android:gravity="center"
                android:minHeight="0dp"
                android:minWidth="0dp"
                android:drawableTint="@color/colorAccent"
                android:foreground="?attr/selectableItemBackground"
                />
        </FrameLayout>

使用roundbutton.xml,如:

<?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#eeffffff" />
    <corners android:radius="110dp"/>
</shape>

它允许我有一个带有居中图标的圆形按钮。 但现在,我希望在点击按钮时产生涟漪效果。

我尝试了很多解决方案,比如这个Tutorial for rounded layouts,但都没有。单击按钮时是否有可以获得可接受效果的技巧? Ripple会很好,但另一个人可以做到这一点我猜...

谢谢:)

===========================================

编辑:

感谢Rockney的评论,它正在使用以下代码:

            <android.support.design.widget.FloatingActionButton
            android:layout_width="110dp"
            android:layout_height="110dp"
            android:backgroundTint="@color/beatiful_yellow"
            android:src="@drawable/ic_file_download_black_60px"
            android:tint="@color/colorAccent"
            android:clickable="true"
            android:background="?selectableItemBackgroundBorderless"
            />

0 个答案:

没有答案