Open maoruibin opened 6 years ago
xml 布局中设置按下背景
<RelativeLayout 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:id="@+id/relativeLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" android:paddingLeft="16dp" android:paddingTop="16dp" android:paddingBottom="16dp" android:paddingRight="10dp">
代码设置
val outValue = TypedValue() holder!!.itemView.context.theme.resolveAttribute(android.R.attr.selectableItemBackground, outValue, true) holder!!.itemView.setBackgroundResource(outValue.resourceId)
xml 布局中设置按下背景
代码设置