I'm trying to use the default android action bar with a custom view:
<style name="ActionBar" parent="android:Widget.Material.ActionBar.Solid">
<item name="android:displayOptions">showCustom</item>
<item name="android:customNavigationLayout">@layout/customNavigationLayout</item>
</style>
The options menu contains a single item which should always show with text:
<item
android:id="@+id/action_cancel"
android:showAsAction="always|withText"
android:title="@string/action_cancel" />
Now I'm having the issue with the selectable background, which is still the size of an action icon:
How can I setup the action bar to apply a selectable background which fills the whole box of the item?
Android Option Menus are the primary menus of the activity. They can be used for settings, search, delete items, etc. We will first create vector assets for the icon. Then we will set the icon in the toolbar items. Similarly, for the background, we will first create a custom style for the toolbar.
Options menu and app bar. The options menu is the primary collection of menu items for an activity. It's where you should place actions that have a global impact on the app, such as "Search," "Compose email," and "Settings.".
android:icon: The icon of an item is referenced in the drawable directories through this attribute. Icon of an ActionBar Item In order to provide an icon to an item, right-click on the res folder, select new, and then Image Asset. A dialog box will appear, choose the Icon Type as Action Bar and Tab Icons.
All applications that use the default theme provided by the Android (Theme.AppCompat.Light.DarkActionBar), contains an ActionBar by default. However, developers can customize it in several ways depending upon their needs.
You can try setting the android:actionBarItemBackground
attribute in styles
, like so:
<style name="AppTheme" parent="android:Theme.Material">
...
<item name="android:actionBarItemBackground">?android:selectableItemBackground</item>
</style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With