android shape透明度40%,android – 正常状态下按下状态透明度的涟漪效应

我希望ViewGroup中的ImageView,当按下时,绘制波纹,这是有效的!但是当按下ViewGroup时,其中的ImageView应保持透明,否则ImageView背景可见:(实际上,您看到的颜色为alpha-orange,是按下时的纹波).

这仅在设备API 21中发生.使用设备API< 21时,我使用选择器,当按下ViewGroup时,图像背景保持透明.

layout.xml

android:id="@ id/item_detail_field"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:paddingLeft="@dimen/margin_left"

android:paddingStart="@dimen/margin_left"

android:paddingTop="@dimen/margin_top_item_field"

android:paddingBottom="@dimen/margin_bottom"

android:baselineAligned="false"

android:background="@drawable/layout"

android:stateListAnimator="@anim/touch_raise"

android:orientation="horizontal">

...

android:id="@ id/item_detail_showfield_icon"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@drawable/button_mini_oval"

android:stateListAnimator="@anim/touch_raise"

android:clickable="true"

android:contentDescription="@null"

android:scaleType="center"

android:visibility="invisible"

android:src="@drawable/show_button"/>

...

绘制/ button_mini_oval.xml

可绘制-V21 / button_mini_oval.xml

android:exitFadeDuration="@android:integer/config_shortAnimTime"

android:color="?android:colorControlHighlight">

我在ripple xml中尝试了很多配置,添加了一个< selector>它可以工作(见下文),但是如果你只是点击ImageView,纹波就不可见了(涟漪动画似乎被剪掉了),只有你按下它才能看到涟漪……

在正常状态下,压力状态下的波纹和透明状态的组合是什么?

android:exitFadeDuration="@android:integer/config_shortAnimTime"

android:color="?android:colorControlHighlight">

解决方法:

删除android:state_pressed =“true”,我找到了2个解决方案,但在这两种情况下我都丢失了touch_raise动画(为什么?):

带有蒙面纹波:

android:exitFadeDuration="@android:integer/config_shortAnimTime"

android:color="?android:colorControlHighlight">

带有未掩盖的小纹波(好于1):

android:exitFadeDuration="@android:integer/config_shortAnimTime"

android:color="?android:colorControlHighlight">

我不知道为什么添加< selector>就足够了在透明背景上有波纹!!!很多人都试图实现这一目标,但这不是谷歌的意图,相反,这种情况非常有用.来源:https://www.icode9.com/content-4-336101.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值