【发布时间】:2022-01-20 15:23:24
【问题描述】:
目前,MD3 使用我认为指定波纹颜色的 50% 的不透明度/alpha 来表示它们在组件上的按下状态。有什么办法可以改变它的不透明度?
这是我目前用来测试MD3中材质按钮的波纹效果的:
<style name="Widget.App.Button" parent="Widget.Material3.Button">
<item name="rippleColor">@color/black_000</item>
<item name="android:textColor">@color/button_filled_foreground_color</item>
<item name="backgroundTint">@color/white_1000</item>
</style>
按钮:
<Button
style="@style/Widget.App.Button"
android:id="@+id/create_account_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/create_account"
app:layout_constraintBottom_toTopOf="@id/log_in_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
在本例中,背景颜色为白色,波纹效果为灰色。如何将波纹不透明度更改为 100% 以使波纹效果变为黑色?我用1.5.0-beta01材质版。
【问题讨论】:
-
您能否添加代码示例,以便人们可以帮助您参考?
-
我认为即使有代码也是不可能的。因此,您可能需要创建一个自定义波纹可绘制类。默认 alpha 设置为 0.5f 。检查类
RippleBackground的来源。
标签: android material-design material-components-android