android - 如何在按下时更改材质浮动操作按钮的颜色?
问题描述
按下按钮时如何更改 FAB 的颜色?我没有看到像onPressed()
.
解决方案
You can use the app:rippleColor
in your layour or the rippleColor
attribute in the FAB style.
Where fab_ripple
should be a selector.
Something like:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:alpha="..." android:color="?attr/colorOnSecondary" android:state_pressed="true"/>
<item android:alpha="..." android:color="?attr/colorOnSecondary" android:state_focused="true"/>
<item android:alpha="..." android:color="?attr/colorOnSecondary" android:state_hovered="true"/>
<item android:alpha="..." android:color="?attr/colorOnSecondary"/>
</selector>
推荐阅读
- python - 替代连续尝试/排除块
- android - ConstraintLayout 中的组阻止设置 ProgressBar 可见性
- python - 把yyyy-mm-ddThh-mm-ss改成datetime,扔掉T分隔符和毫秒
- javascript - 在空手道中循环使用不同参数的相同特征文件
- spring - Can I invoke a local bean into a ear file from a Javax-WS into a war file- apache-tomee-plus-1.7.4
- javascript - Angular 2+ Window attribute undefined
- python-3.x - PyCuda program keeps on running
- javascript - Ajax Php Image Upload and Save
- android - Unit test android using synchronous call retrofit 2
- json - PostgreSQL 从现有数据创建 JSON 列