I designed an app on the phone and am moving it to tablet. Testing on 3.2, a Samsung something-or-other. The legacy menu doesn't fill the screen using existing resources...
So, notwithstanding this, how can I make my menu fill up the horizontal space? (Besides playing tricks with wide images, if that would even work.) Again, I'm not interested (yet) in doing the action bar overflow thing.
This is not supported by the SDK. The layout of a menu is determined by the OS, occasionally modified by the device manufacturer. You, as an SDK app developer, do not have control over sizing, number of rows/columns, etc. In effect, the "menu" is an abstraction -- you simply indicate what items should be in there, and the visual representation of that is up to Android. That's why, for API Level 11+, there are zero code changes required to use an action bar, other than to have android:targetSdkVersion set to 11 or higher.
Related
Seems Android is displaying notification icons in different places depending on OS or device.
Usually it's on top left corner, but sometimes, it's left side but centred with text. Does anybody know what is the logic behind it?
Examples:
Centered
Top left
Seems it's not related to OS so much as I have seen both versions on same versions of Android. Maybe something else?
Different releases of Android have changed the UI styling for notifications - your first example is from Marshmallow (Android 6) or before, the other is what it looks like on modern versions of Android. And that's just for stock Android - almost every phone manufacturer adds their own tweaks to the UI to some degree, and if they decide to make changes to the standard layouts, they can!
If you want to create a notification, it's recommended you use the NotificationCompat support library. This allows you to configure the notification in different ways, so you get a few standard variations. Using the support library means you can use configurations that weren't supported by the notification system on older OS versions, and they'll use safe fallbacks.
How those standard variations will actually appear depends on the device - for consistency, all notifications on a device will follow those standard templates. You wouldn't be able to get your modern example mixed in with the old Holo style, it would look weird because the styling is completely different.
It's ultimately up to the OS to decide what notifications should look like, you just provide some attributes like different text labels, an image, media content, etc. and it decides what to do with them. That's why the old style puts the icon in a big circle on the left, with the two bits of text displayed that way, and the newer version uses a small icon inline with the app name, etc.
It is possible to create a custom notification, where you can basically define the whole content and have control over the UI, so you could have completely mismatched notification styles on the same device - but I don't think you'd see that much, since it would make your app look strange on devices where the UI doesn't match. And like that link says, from Android 12 onwards you're only able to customise an area of the notification, which doesn't include the standard header (app icon and name, timestamp etc)
Quick question, Android related..
How do I display a working "THREE VERTICAL-DOTS" floating action button, to trigger same functionality as Android menu button that worked on Kitkat (Android-4), and all previous Android versions?
Details:
I have an Android app that uses Java Native Interface. It worked fine in Kitkat (Android 4.x series), but in Android 5.x, the menu-options button (three vertical dots) no longer responds. Originally, in Kitkat (Android 4.x), the standard Android menu button brought up the applications configuration menus. Now, in Android-5, the Menu button has been replaced with a "Recent Apps" button (this was a very poor design change - probably the worst basic re-design of a working interface I have seen in 30 years... ). Is there an easy way to use a "floating action button" or something like that, to restore functionality of the standard Android "Menu" button?
On Samsung tablets, one can tweak: "Settings / Accessibility / Dexterity and interaction / Assistant menu " to "On", and then a floating-action-button appears, which then has the three vertical-dots as one of it's optional push-buttons, if invoked. Pressing that three vertical-dots button (on the Samsung FAB (floating-action-button)), triggers the old Kitkat/Android4 menu, and at least Samsung users can alter set my app config parameters.
In my app's AndroidManifest.xml file, I have minSdkVersion="8" and the targetSDKVersion="8". I have tried setting the targetSDKVersion to higher levels, which results in a non-functional floating action button, showing three vertical dots, appearing on the screen.
There must be an obvious way to fix this damage that the Android "Material Girl Design" people did to Android Kitkat(and previous Android vers.) Android Menu Button. I've detailed a work-around for my user-base at this point, and released an new app version which offers details on the work-around - at least for Samsung phone and tablet users, but an in-app button really should just appear to allow the main app configuration menu to be triggered.
I have looked at this:
http://developer.android.com/training/appbar/setting-up.html#utility
Don't want an "Action Bar". My app is a DOS-emulator, and needs all the screen space.
I have also reviewed:
Android Options Menu in Fragment
This gets closer, but rather than trial-and-error, I would like to just jump to the solution, if possible. There must be some code or a feature selection that just fixes the little action button that appears (but does not work), when I set the targetSDKVersion="12" (or higher values), in the AndroidManifest.xml file.
My app uses SDL (Simple DirectMedia Layer) vers. 1.2 and 1.3 to control and draw the screen.
I will post the answer here when I find it. I know it is possible, because Samsung is already doing this, within its "Accessibility/ Dexterity.. /Assistant Menu" feature.
I created an app with minimum SDK 7 in order to get maximum compatibility with circulating devices. On Android phones (GB2.3), pressimng Menu button pops up a menu strip on the bottom of the screen, and that is correct.
However on HC3.2 tablets, where no menu hardware key is present, I expected a soft-menu key on the bottom of the screen, but it didn't appear, so I can't open my menu.
I don't know where to investigate and which portion of my code to share, so could you please show me where do I have to look for menu softbutton?
After reading that menus are deprecated in most recent Android versions, I don't know if ICS4 has a soft-menu button or not. I never tested my app on such a device. Can you give me advices?
Thanks
The link you provide tells you how to correctly provide action bars in your app so that the presence or otherwise of a physical menu button is irrelevant, so that's a good start.
Now, you need to combine that with a little runtime detection of the SDK version (just check the Build.VERSION.SDK_INT constant for Android 1.5 or above), along with some appropriate reflection to enable the same APK to run on any Android version starting with your minSDK version.
In the past I've kept my game's options behind the physical menu button for these reasons:
I don't have to have on-screen buttons in-game.
The menu action is consistent with the android user experience; it's not something unique to my app.
In some situations Android provides a soft menu button in the bottom system bar. Looking forward, though (e.g. with recent devices and targetSdkVersions), it seems there's no guaranteed way to have a menu button without implementing the new ActionBar.
If my understanding is correct, I see these options:
Use the ActionBar. Say goodbye to a big chunk of screen real-estate, especially in landscape orientation.
Implement my own on-screen menu button. I've seen this in other games, and it strikes me as inconsistent and terrible.
Target an old sdk version. I don't like this.
Is my understanding correct? Anyone have additional suggestions for my list?
relevant links:
http://developer.android.com/design/patterns/compatibility.html
Android Menu Button on 4.0 Devices
Android 3.0 statusbar & targetSdkVersion in manifest, menu button
android honeycomb menu button target
You could implement a tiny , transparent menu button of your own. Many games do that. That way you are not dependent on anyone and you don't loose any screen space.
Edit : Your menu button could then have follow your game's design.
Is my understanding correct?
Yes.
Anyone have additional suggestions for my list?
Your definition of "terrible" differs from mine. IMHO, any game that has its own stylized graphics and look (i.e., just about anything using the Canvas or OpenGL) should have implemented its own "menu" from the outset, and therefore largely would be oblivious to these changes.
I need to compensate for the lack of a physical (or even a "soft") menu button on Android 3 tablets. The app I'm working on generally hides the title bar for its activities, but I can't do that if I want the action bar to appear on a tablet. Is there something in the API that I can use to determine whether a device has a menu button?
If I can't find such a function, the only thing I can think of to do is to never hide the title bar on Android 3.0 and later, but that bothers me for two reasons:
I believe Android 3.0 (or a later API) will eventually support phones, which will probably have menu buttons
I would prefer not to hard code that SDK version (perhaps I could never hide the title bar for Android 3.0 and above, but then I run the risk of not hiding the title bar on phones)
LeffelMania has the right idea, but there is a caveat: If you target SDK 11 (3.0) and use a no-title-bar theme or override with a custom title of some sort, you will be just plain menu-less, because on Honeycomb devices with the target set to 11 the options-menu lives in the title bar itself instead of a fake menu button in the bottom status bar. So be careful there! (You can work around this by setting a lower target, or targeting style resources to v11 to use a one of the Holo themes with a titlebar in that case).
DEPRECATED: This answer is no longer accurate, given changes to the Android framework and design guidelines.
Android phones are guaranteed to have a Menu button. All phones pre-Honeycomb have Menu buttons, and Honeycomb features an ever-present software button. If you use the proper callbacks that tie into the Menu button (onCreateOptionsMenu(), onOptionsItemSelected(), etc) you will be safe to receive those callbacks on any device running Android.
As of API level 14, ViewConfiguration.hasPermanentMenuKey() is available to indicate whether a permanent menu key is present.