android: how to set overflow menu in aciton bar - android

i am trying to customize my action bar, and willing to put some actions into the overflow, so i used showAsAction="ifRoom" in my menu xml file.
the problem is, my action bar doesn't want to take more than 2 action(is this normal?), and don't show the overflow menu which is supposed to be included if there's not enough space in screen.
any hints or solutions please?
Thank you

To get it to show on an Android 4.0 device (not 100% sure it will work on older devices, but it may with the compatability package) I also had to add android:uiOptions="splitActionBarWhenNarrow" to the AndroidManifest.xml file in either the <application /> or <activity /> section depending on the usage you want.
Also, showAsAction="ifRoom" will most likely not show them... try using showAsAction="always" to get it working at least and then try playing with them!
Hope this helps....

Related

Android full screen without three dots

I create empty app. I want set full screen without three dots(menu/search/back).
Please help!
Set in the manifest
<activity android:theme="#android:style/Theme.NoTitleBar.Fullscreen" .... >
If you use a tablet you cannot get rid of the system bar. You may be able to get rid of the navigation bar and status bar on phones. Please read the "Controls for system UI visibility" section of the Android 4.0 SDK release notes. http://developer.android.com/sdk/android-4.0.html

Customize the action bar of android app with an image

I am creating an android application and I want to customize the look and feel of the action bar of the application.
For my project I am using actionbar sherlock. Currently my app is looking like this:
I want to remove the logo of the application and also the application title from the action bar and replace it with the following image.
Is there any way to accomplish this. I have read that we have to use the style tag to do this. But since I am new I don't know where to write the style tag and how to implement this. Please help...
EDIT
The width of the new image should be adjustable i.e. my requirement is that its width should cover half of the action bar
All I want to achieve is something like this application which is available in play store.
Just use this line in your onCreate method:
Drawable d=getResources().getDrawable(R.drawable.action_bar_background);
getActionBar().setBackgroundDrawable(d);
That will change the background of your actionbar to whatever image you want.
Of course it is always important to have different sized images for different device sizes.
I hope it helps
Update your AndroidManifest.xml tag to include the :icon attribute.
See the developer docs for more information.
Example:
<application
android:logo="#drawable/my_logo"
....>
</application>
Another nice example, for use with a theme/style can be found here.
To hide the title text shown on the action bar see this post's accepted answer. You'll need to have a custom style applied to the action bar to hide the text. If you also want the icon to be larger than the allowed space, you'll need to also set the background of the action bar as explained by #Eenvincible.
It's also worth noting that you're breaking a lot of Android Design Guidelines. It'd be easier for you and better for your users to simply set the right icon/title and move on with the standard ActionBar look/feel. Worth a look: Android Design Patterns - ActionBar.
What you are seeing is actually the default icon. Replace ic_launcher.png file from the following folders(if it exists there) with your image.
/res/drawable
/res/drawable-ldpi
/res/drawable-mdpi
/res/drawable-hdpi
/res/drawable-xdpi
/res/drawable-xxdpi
Also rename your image file to ic_launcher.png
To edit the text on right of icon, you can use:
getSupportActionBar().setTitle("ANY TEXT HERE");

Remove Android options menu in XE5 Delphi

Is there a way to completely remove the Android options menu in XE5 Delphi? I've been testing my application on a HTC One and because my phone doesn't have a menu button and my application doesn't have an options button, android automatically adds a options menu. Since this button is added by Android there is no way to add items to the menu.
I've already tried to change the minimal SDK version, but this makes the application very unstable and makes it crash when the orientation is changed:
<uses-sdk android:minSdkVersion="14" />
Is there an other way to remove the options menu? Now there is just a large options menu in the bottom of my screen that has no menu items.
Ok, you're right in that this empty action overflow menu is added because of your lack of hardware menu button.
On a Nexus 7 it's not such an issue as the empty overflow menu is added at the end of the other soft buttons.
On a HTC One, however, you can configure the Home button to act as a menu button, which removes the action overflow button.
It's not correct to say you can't add items to the menu. My Android session at CodeRage 8 shows how to add menu items. However, I'll grant you, it's a bit of a faff.
In order to remove it, the docs say you should set the targetSdkVersion attribute (not minSdkVersion) in your Android manifest to 14 (see this blog post for details). However having tried this it causes a crash if you don't prevent rotation in the RTM version of XE5, as you saw with your tests. This issue is sat in QC, logged some weeks back, hopefully to receive a fix in the near future.
However you should consider restricting the rotation as one course of action...... This is easy enough.
you must change in manifest android:configChanges="orientation|keyboardHidden">
to:
android:configChanges="orientation|keyboardHidden|screenSize">
then you can set minsdk, maxsdk, targetsdk as you want, and application will not crash

Android ActionBarSherlock duplicated menu button

I use ActionBarSherlock on my app compiled with Android 4.0.3.
When testing on my device running JellyBean 4.2.1, I can see the overflow icon both in the ActionBar and in the bottom buttons bar.
See Screenshot.
How can the bottom overflow button be removed?
EDIT: Both buttons work!
Increase your android:targetSdkVersion to 14 or higher, as I outline in this blog post.
I create a menu like that in my app and have some items in a menu.xml that looks like this:
<item
android:id="#+id/menu_main_about"
android:orderInCategory="100"
android:showAsAction="never|withText"
android:title="Acerca de"/>
Maybe you are supplying some extra or different attributes that cause that behavior. Please try with this to confirm that.
In the samples that brings the ActionBarSherlock, one's of these are what you need.

Hide&show action bar on pre-honeycomb devices

The action bar can be shown even on pre-honeycomb devices, as shown via the actionbar-compat sample.
I want to be able to hide and show the action bar on demand (programmatically). How do I do that?
The problem is that getting the action bar using the support library returns null. I've also tried to find it using its id and set the visibility to gone, but it just showed a white space instead.
in the end i've used actionBarSherlock.
it has much more features and this requested feature is one of them. maybe the new support library works with this feature , but i've already moved to this solution.
ok , i have a workaround , but it doesn't work for the beginning , meaning that for a very short time , the actionbar will be shown on the beginning.
here's the code i've created to hide the action bar (for pre-honeycomb versions) ,which i've thought of by looking at this post :
ViewGroup decorView = (ViewGroup) this.getWindow().getDecorView();
ViewGroup root = (ViewGroup) decorView.getChildAt(0);
View titleContainer = root.getChildAt(0);
titleContainer.setVisibility(View.GONE);
if anyone knows how to make the action bar hidden on the beginning and choose when to show it , please let me know.
EDIT: btw, if anyone wishes to use a theme via the manifest and uses actionBarSherlock, you could use either "Theme.Sherlock.Light.NoActionBar" or "Theme.Sherlock.NoActionBar" , and if you wish to hide&show in code, simply use getSupportActionBar().hide() and getSupportActionBar().show().
Try this,hide action bar in xml by setting following property in xml for your activity.
`
<activity
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
Hope it helps if not then add a comment and if anything is wrong with my answer please correct me.

Categories

Resources