Oli*_*dam 5 android material-design material-components-android
目前,MD3 使用的不透明度/alpha 为指定波纹颜色的 50%,用于组件上的按下状态。有什么办法可以改变它的不透明度吗?
这是我目前用来测试 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>
Run Code Online (Sandbox Code Playgroud)
按钮:
<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" />
Run Code Online (Sandbox Code Playgroud)
在此示例中,背景颜色为白色,波纹效果为灰色。如何将波纹不透明度更改为 100%,以使波纹效果变为黑色?我用的是1.5.0-beta01材质版本。
我真的不认为你可以改变波纹颜色不透明度,因为它是由框架决定的。对于具有棒棒糖及以上版本的设备,它由RippleDrawable类处理;对于预棒棒糖设备,它由RippleDrawableCompat类处理。
波纹不透明度将由 Android 框架(如果可用)决定。否则,当按下按钮时,该颜色将以 50% 的不透明度覆盖在按钮上。
来自MaterialButton文档。
如果您确实想要纯黑色波纹,您可以尝试使用选择器标签创建自定义可绘制对象,并将其设置为按钮中的背景,并将backgroundTint 设置为“null”。不过我不建议这样做。
| 归档时间: |
|
| 查看次数: |
1752 次 |
| 最近记录: |