I tried to add an icon to the Action Bar, in ShowAsAction I set it to ifRoom. But no matter how, the icon only shows up in the 3 dot menu and never show up in the Action Bar, what are the possible cause of this issue?
Related
I'm looking to show the action bar "action mode" persistently throughout the life on an activity. This activity edits an image and once the user clicks the check mark the image is saved and the activity exits. However, if they press back the edit process is canceled.
My action bar is translucent with overlay content set to true. Here is how it looks.
Here is what I have tried
1. Action bar is translucent as well as my action mode. Action mode is overlayed causing a darkening of the action bar.
2. Make action bar transparent. Everything looks good but once you click the check mark you see an odd looking action bar without a background which is shown for a second.
3. Hide the action bar. This causes animation issues where you can see the action bar animate in while the activity is exiting.
All these attempts are hacks and they don't work well. Maybe I can somehow add the check mark on the left? I'm not sure how to reproduce that action mode as my action bar. Hopefully someone has a good idea on how I can achieve the action mode style.
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.
Let me explain my current scenario.
I have a split action bar. From what I understand all action items will go to the bottom of the split action bar. I want to have some action items in the top action bar so I made a custom action bar by making an xml file for it.
In my onCreate, I have this to set up the top action bar...(custom_actionbar is an xml file I made.)
getActionBar().setDisplayOptions(
ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP
| ActionBar.DISPLAY_SHOW_CUSTOM);
View view = View.inflate(getApplicationContext(),
R.layout.custom_actionbar, null);
getActionBar().setCustomView(view);
So this works to set up the top of the action bar.
Now I am getting closer to my problem. I can currently get an action overflow icon in the bottom of the split action bar, but I want the icon to be at the top of the split action bar.
For a simple action bar it is possible to set the action overflow icon by doing android:showAsAction = "never" in the respective menu xml file.
HOWEVER, if I am doing a custom action bar for the top, I can not do this. This will only apply to the bottom action bar as all of the elements in the respective menu xml file will go to the bottom of a split action bar.
Does anyone know how I can get the action overflow icon to appear at the top of the split action bar or should I remodel everything in a different way? Like just have a normal action bar and then have some strip to hold image buttons at the bottom to mimic a split action bar? Or is there a way to get the elements in the menu xml file to go to the top of the split action bar?
Any Help is appreciated.
Thanks
By what i understand you want to have the overflow menu in the top action bar which is a custom xml file. You can actually mimic that overflow menu icon and the options list in the custom xml file if required. It is basically a hack to use popup windows with a list adapter to mimic the overflow menu behavior. Check the link: http://rajeshandroiddeveloper.blogspot.com/2013/07/android-popupwindow-example-in-listview.html
Hopefully this solves you problem.
So there is no real "good" way of having the action overflow button in the top of a split action bar menu. There are several ways that one could go about doing this.
Create a custom view for the top, have an image button that represents the action overflow menu icon and launch a pop up menu onClick to simulate the action overflow menu.
Create a regular (single) action bar and then create a custom view that will be at the bottom of the activity that will resemble the bottom of a split action bar. The action bar can get the action overflow menu if at-least one menu item is set to android:showAsAction = "never"
I personally went with option 2 because I could not find a suitable icon that represents the action overflow icon.
I am using the action bar in my app, and I have two qustions:
1 As the image below, the items(item 1,item 2, item 3) is displayed without icon, is it possible to show the icon?
In fact the icon is set in the menu.xml.
2 Is it possible to know if the action bar is split-ed?
I use android:uiOptions="splitActionBarWhenNarrow" to make the actionbar split-ed if necessary, but I want to know if it is split-ed in the runtime.
I have an action bar where I have an icon of my choice. I want this icon to appear under three dots icon, which appears only as a result of overflow of action bar, when it lacks space. I want my action bar icon appear only as a sub menu of three dots button, not as a top level icon. How should I achieve this? Can I force this three dots icon to appear always in action bar, regardless of how many icons fit?
In your menu's XML, add android:showAsAction="never":
<item
android:id="#+id/always_in_overflow"
android:showAsAction="never"
android:title="#string/your_menu_item_title"/>