我使用支持包中的新工具栏。
在 Android 5.0 上,我的触摸效果很好。 在较低版本上,我也会得到一个按下状态,但它非常微妙。
如何更改工具栏菜单项的按下状态?
最佳答案
您可以使用以下方式更改样式中的按下状态效果
<item name="selectableItemBackground">
@drawable/selectable_item_background_selector
</item>
<item name="android:selectableItemBackground">
@drawable/selectable_item_background_selector
</item>
在 Android 5.0 上,您可以覆盖“style-v21”中的样式并设置波纹可绘制对象(在 drawable-v21 中):
<item name="android:selectableItemBackgroundBorderless">
@drawable/ripple_selector
</item>
要仅更改工具栏的按下状态样式,您可以设置自定义主题
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
app:theme="@style/ToolbarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"/>
关于android - 如何更改支持工具栏菜单项的 onPress 行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27126805/