how to highlight a menu item on selection? [duplicate]

送分小仙女□ 提交于 2019-12-09 03:39:42

问题


How to highlight menu item on selection, I tried modifying styles.xml with various attributes like colorPressedHighlight, colorActivatedHighlight, etc. Is there any way to keep the menu item focussed until other item is selected?

AndroidManifest.xml:

<style name="onPressedHighLight" parent="AppBaseTheme">
    <item name="android:colorActivatedHighlight">@color/OnPressed</item>
</style>
<color name="OnPressed" parent="AppBaseTheme">#FF0000</color>

Activity file:

setTheme(R.style.onPressedHighLight);

回答1:


Use selector for custom buttons. Search in google for more examples. Here is one.



来源:https://stackoverflow.com/questions/15717356/how-to-highlight-a-menu-item-on-selection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!