我已经为视图编写了波纹效果代码。这是我的代码:
styles.xml
<style name="SelectableItemTheme">
<item name="colorControlHighlight">#1e333d</item>
</style>
<style name="SelectableItemBackground">
<item name="android:theme">@style/SelectableItemTheme</item>
<item name="android:background">?attr/selectableItemBackground</item>
</style>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<RelativeLayout
style="@style/SelectableItemBackground"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true">
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
我的议程是每次用户触摸视图时更改颜色(随机)。