【问题标题】:ImageView with rounded edge Circle ripple带有圆边圆形波纹的 ImageView
【发布时间】:2018-09-20 17:24:29
【问题描述】:

我正在尝试模仿这种效果:

但我做不到,我一直在这样做:

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:color="#fff"
    tools:targetApi="lollipop">
    <item android:id="@android:id/mask">
        <shape android:shape="oval">
            <solid android:color="?android:colorAccent" />
        </shape>
    </item>
</ripple>

【问题讨论】:

    标签: android android-layout imageview ripple


    【解决方案1】:

    您不需要任何自定义背景,只需像这样使用 ImageButton:

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="?attr/selectableItemBackgroundBorderless"
        android:src="..."/>
    

    您可能还需要添加填充。

    【讨论】:

    • android:focusable="true"android:clickable="true" 也是需要的。
    • 我按照你说的做了,但是没有用。
    • SamuelEminet 我从来没有在没有这些属性的情况下工作过。 @Paul 尝试使用?android:attr/...
    • @SamuelEminet:
    猜你喜欢
    • 2021-01-16
    • 1970-01-01
    • 2021-06-23
    • 1970-01-01
    • 2017-09-13
    • 2019-10-19
    • 1970-01-01
    • 2015-07-21
    • 1970-01-01
    相关资源
    最近更新 更多