gpt4 book ai didi

Android 纹波 : How do other apps make their ripple so transparent without affecting the original colour of the view

转载 作者:太空宇宙 更新时间:2023-11-03 12:16:45 25 4
gpt4 key购买 nike

当您查看 yPlan 或 Google Play Store 等其他应用时,它们对按钮的涟漪效应就像浅灰色或黑色,不会改变整个按钮的颜色。

我想要同样的效果。

这是我试过的,但不一样

这是我的颜色控制亮点:它是具有 99% alpha 的灰色

    <color name="colorHighlight">#fc8c969f</color>

这是我的按钮的波纹抽屉

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<item android:id="@android:id/mask" android:drawable="@android:color/white"/>
<item android:drawable="@color/colorAccentWith92PercentOpacity"/>
</ripple>

请注意,drawable 是将按钮的颜色设为黄色,因为我不能使用 android:background 两次

最佳答案

<?xml version="1.0" encoding="utf-8"?>
<!--Use an almost transparent color for the ripple itself-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#22000000">

<!--Use this to define the shape of the ripple effect (rectangle, oval, ring or line). The color specified here isn't used anyway-->
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="#000000" />
</shape>
</item>

<!--This is the background for your button-->
<item>
<!--Use the shape you want here-->
<shape android:shape="rectangle">
<!--Use the solid tag to define the background color you want (here yellow)-->
<solid android:color="#ffff00"/>
<!--Use the stroke tag for a border-->
<stroke android:width="1dp" android:color="#ffff00"/>
</shape>
</item>
</ripple>

关于Android 纹波 : How do other apps make their ripple so transparent without affecting the original colour of the view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32358917/

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