gpt4 book ai didi

android - 在 ImageButton 中使用 Elevation 和 Ripple

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:11:38 26 4
gpt4 key购买 nike

我试图在 ImageButton 上同时设置高度和波纹效果。我正在运行 LOLLIPOP。

代码如下:

    <android.support.v7.widget.AppCompatImageButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="5dp"
android:background="?attr/selectableItemBackgroundBorderless"
app:srcCompat="@drawable/add" />

我的主题是:Theme.AppCompat.Light.DarkActionBar

使用此代码,我只会产生涟漪效应。如果我删除背景(波纹),我会得到提升。

已编辑:

注意:所有屏幕截图都是在单击(长按)图像时截取的。

我已经用 android:background="?attr/selectableItemBackground" 进行了测试,我得到了一个波纹,背景是一个正方形,但没有高程:

使用 android:background="?attr/selectableItemBackgroundBorderless" 我得到了圆形背景的波纹,但没有高程:

没有 background 属性我得到了海拔,默认的 ImageButton 背景:

我需要的是同时具有圆形波纹背景和高程

最佳答案

像阴影一样,无边界波纹会转换到最近的父表面上——这意味着它们无法转换阴影。考虑改用带边框的波纹:

android:background="?attr/selectableItemBackground"

关于android - 在 ImageButton 中使用 Elevation 和 Ripple,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37034009/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com