以下为官方Meterial样式下的列表Item和Button预设的Ripper Drawable:
...
@drawable/item_background_material
@drawable/item_background_borderless_material
@style/Widget.Material.Button.Borderless
以下为item_background_material.xml:
android:color="?attr/colorControlHighlight">
以下为item_background_borderless_material.xml:
android:color="?attr/colorControlHighlight" />
以下为Widget.Material.Button.Borderless对应的设置和xml:
@drawable/btn_borderless_material
@null
android:color="?attr/colorControlHighlight">
android:drawable="@drawable/btn_default_mtrl_shape" />
引用如下:
...
android:background="?android:attr/selectableItemBackground">
ImageView设置如下:
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:background="?android:attr/selectableItemBackground"
app:srcCompat="@mipmap/ic_launcher" />
注意: 一定要设置 android:clickable="true" 或者 通过代码设置 setOnClickListener(...) .
你要用这些个酷炫的东西是有代价的, 就是你的设备必须是Android 5.0 (API level 21), 低于这个版本的机器是不支持的.