【发布时间】:2017-03-13 11:10:01
【问题描述】:
如何定义具有自定义背景和属性"?attr/selectableItemBackground"的Button?
使用此代码,"?attr/selectableItemBackground" 属性被忽略,它不显示触摸反馈。
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:foreground="?attr/selectableItemBackground"/>
使用这个其他代码,可选择的工作,但我失去了背景颜色:
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"/>
【问题讨论】:
-
你可以改用
rippledrawables。 -
但我不想为 API>21 创建一个涟漪,为 API
标签: android material-design android-view android-button android-attributes