I was wondering if you can just put plain text as a button in the action bar. I was messing around with a spinner, but i just dont really care for how it looks, but I do like how it says something instead of a picture (icon). I dont really like how its forced on the lfet side of the action bar by my icon.
Can i just make a 'button' that says options that I can make appear on the right side. In one of my other apps I did this on the right side, but it was just using an icon as a menu. Can you use a text button as a menu?
Try to remove the android:icon attribute from your menu XML :
<item android:id="#+id/my_id"
android:title="#string/my_string"
android:showAsAction="ifRoom|withText" />
Or try to use the Icon Generator from here, chose the Text tab and generate your icons with the provided text.
In your menu.xml, you simply remove the android:icon="#drawable/ic_someicon" entry. This means that the Action Bar entry becomes whatever is in the android:title="#string/some_menu_title" attribute instead; that is, it becomes a button with text rather than a button with an icon.
Related
Im making an app for android, without actionbar.
What is best practice for showing titles without actionbar?
The best practice is basically never using an action bar. This gives you a complete device screen to play with.
You can use images or different text styles for showing the title. You can also use interesting icons.
To remove action bar -
Go to res > values > styles.xml
Here is an illustration of styles file -
You can use the Toolbar (it's like the action bar, but more flexible). For example, action bar needs to be on top of the screen, but toolbar can have place anywhere in the layout.
You title can be shown as text or a beautiful asset.
If, for some reason, you don't want to use the toolbar, you can think about something like having a scrollView with the title on top of it.
Use a regular LinearLayout with a TextView inside. Style according to your needs, and set the text in the xml, or programmaticaly using TextView's setText() method.
I have an action bar that has a specific theme to it(some sort of color) that I want to apply to all activities/fragments that looks something like the attached picture.
Then once I click the dropdown, I'd like the dropdown background to be a different color. How would I go about styling that background.
Right now this is theme I have
<item name="toolbarTheme">#style/ThemeOverlay.AppCompat.Dark.ActionBar.WhiteDropDown</item>
Once I click the dropdown menu, the background of the dropdown appears to be black. What should I do to change that?
I've tried creating a subclass of #style/ThemeOverlay.AppCompat.Light and change the entire toolbarTheme to that style. But at the same time, the actionBar texts now all appear in black since its style is Light, and to contrast that, the texts will be black in default. Therefore, I'm wondering if there's any other attribute I can modify just to change the background of the dropdown menu.
I've tried, actionMenuTextColor, actionBarPopupTheme, spinnerDownItemStyle, actionBarItemBackground, actionDropDownStyle, and everything I can think of. Someone please help out!
Thanks!
I want to customize navigation drawer app compact action bar, I want to remove app icon from that and want to make its title center in action bar.
I have applied all solutions , but nothing is working with all the conditions.
Please give me some clue for applying it correctly
You should creat a customize action bar. Then, if you want you can add a button that can open and close your drawerlayout.
I have solved my problem. As mentioned, I have two problems, and I solved that in following way :
1) For making title centre, we need to make custom layout of action bar, and need to remove action bar title.
2) for remove app icon from action bar, we need to set android:icon property of that activity in manifest with transparent image or colour.
In my android application, I have an item in the menu, and I want the item display all the time with the icon and the text, this is the setting:
<item
android:id="#+id/menu_submit_back_tomap"
android:title="#string/menu_back_tomap"
android:icon="#drawable/ic_action_back"
android:showAsAction="always|withText"/>
However I can only see the icon, the text is not displayed, what's the problem?
BTW, this is the only item in the menu.
It depend on available space if there will be space to display text it will be displayed if not then only icon will be displayed.
" The "withText" value is a hint to the action bar that the text title should appear. The action bar will show the title when possible, but might not if an icon is available and the action bar is constrained for space." - android developer
http://developer.android.com/guide/topics/ui/actionbar.html
it have two reason to not working always option:
there is no more space in actionbar because of too much icons.
if you are using custom theme then you have to use
yourapp:showAsAction="always"
rather than
android:showAsAction="always|withText"
Are you using the support library? If so, you are supposed to do it differently:
Android 4.3 menu item showAsAction="always" ignored
I've used the action bar style generator to generate a custom action bar theme for an app, and it works well after a few tweaks. My custom theme is based on Holo (the dark version) and changes the highlight colours. My action bar overflow menu correctly shows my custom state_pressed colour on the overflow items when I press them. I've set android:colorPressedHighlight to the colour I want, and put an appropriate drawable for android:selectableItemBackground.
The problem is on one of my test devices, which has a hard menu button. (It's a Samsung Galaxy S III.) When I show the overflow menu with the hard menu button, pressing an item from this menu gives it the default blue highlight. Either it uses another attr instead of android:selectableItemBackground, or it's taking it from another style. I'd like to know what attr it's using, or what style it's taking it from, so that I can set this colour.
P.S. Before anyone suggests it, I know that you can use android:panelBackground to set the background of the bottom menu. But I don't want to change the overall menu background, only the item background.