Is it possible to change the behavior of native keyboard to float-able? I want to move the android keyboard to center of the screen. Is it possible? Or else I need to create a custom keyboard? I read this answer. But here no detailed explanation for why we can not move the position. I want to know the clear reason for why we can not change the position?
First- there is no "native keyboard" in Android. There's a default keyboard, which can differ by OEM. There's no one single keyboard app that you can assume is installed on all, or even a majority, of systems.
Secondly, very few keyboards support a floating mode. Its a pain in the neck to do, Android is written with the assumption that the keyboard will be a rectangle laid out below the app. You have to jump through a lot of hoops to do floating, using APIs that aren't well documented. Most keyboards don't do it. (What you need to do is play with a semi-documented feature called insets, telling the framework that you're keyboard has 0 permanent height but full screen temporary height and restrict the touchable inset to just the area you plan to take up so that other touches fall through. And since these features are all non-documented or poorly documented, really only the people who have studied them in depth will figure out how to do it).
Third, there's no API to force even those keyboards that do support it into floating mode. Android itself has no concept of a floating keyboard, so it can't tell a keyboard to float.
Basically, the keyboard API in Android on both sides is really bad. The original company that wrote Android didn't ever really think people would come up with all the great ideas for input that they have- they just thought it would be people supporting new languages and graphical skins. So they didn't make a great API. And for whatever reason, they haven't really improved the API all that much, or brought common concepts like that into the OS. Unless they decide to spend serious engineering effort on improving it, I woldn't foresee things like that changing.
Related
I'd like to create an Android app that can modify the whole display, even when the app is not being used directly. This is one example of an app that seems to do this.
Ideally, I'd not only want to be able to tint the screen, but to perform arbitrary operations on the pixels being shown on the display, ranging between making the entire screen a solid color, inverting the colors (so that e.g. black becomes white), and blurring the screen. (I could imagine this level of access in the wrong hands could make somebody's phone unusable, so maybe not all of these are possible.)
Any pointers on how to do this?
You want to let your app draw over other apps. There is a special set of requirements for such applications.
Take a look here and here.
There is also a simple tutorial.
And an opensource app, that looks pretty similar to one you've linked above.
It is possible to determine if the keyboard is visible from an activity but is it possible to determine from a background service? I'm developing a floating action button feature that's pinned to the bottom, however, when the keyboard comes up I want to re-position the floating action button.
Its actually not even possible to do from an Activity. There's some code that's widely distributed that tries to do it, but its based on a hack that may or may not work under all circumstances. I wouldn't rely on it. Particularly it has problems with split screen mode, alternative keyboards with very small heights, and when screen casting to different size monitors. Under all those circumstances it has a tendency to break. It may work some of the time, but its not reliable.
How to avoid 'blind pixels'? S8's round-cornered screen may affect layout in a significant way. How to know where I can safely draw anything, and where I have to be aware that some part of drawn pixels may never actually display?
I don't want to force non-fullscreen mode. I just want to know where is my "safe rect". How to get that information?
(possibly in a way that can be applied to every phone no matter what company manufactured it, but device-specific solutions are also very welcome)
edit: added picture for everybody still in 2016:
I'm writing my first Android game, and though the game itself is working well, I'm not too sure about some of the Android integration aspects of it. Specifically:
Should I provide an in-game volume control?
Should I hide the status bar?
Is the Menu button generally used to pause the game, or should I provide an on-screen control for this?
etc.
Basically I just want my game to do everything the "standard" way. I don't want to frustrate users. Is there some resource (official or not) that lists recommendations for such things? Alternatively, can anyone give me a few important guidelines?
There are no official guidelines how to do this, but some 'Android common sense' would be advisable.
As usual, there is more than one way to do anything, but most of the apps seem to follow the following principles:
full screen games (especially ones in landscape mode) seem to hide the status bar most of the time
you should override the menu button, so it does not get pressed accidentally, but provide a quick way to leave the game
back button usually pauses the app
you do not need in-game volume control since all of existing android devices include a volume rocker, but make turning the volume off available as soon as the game (splash screen) starts, preferably give the person a few moments to turn it off before the music start (a 'would you like to turn the music down?' dialog would be nice)
an (as usually on android) don't count on anything and specify special game requirements (trackpad support, min screen size, ...) in the manifest file
hopefully you can find some more resources online
Are there any android zooming solutions that can be applied to a generic android view?
My app needs to push a lot of information onto the screen, and on some phones, screen is so small that this data becomes unreadable.
I want to get zooming functionality that works for textview's and image buttons in particular. I imagine a zoomView that works for these two built-in's would work for most of the others too.
I've looked around on the web and haven't found any easy solution yet. Most of the discussion seems to be focused on zooming images or a webview.
If there is not an existing solution, can anyone suggest a good approach to take?
Are there any android zooming solutions that can be applied to a generic android view?
That is not possible except perhaps on Android 3.0. On Android 3.0 (API Level 11), you have getScaleX() and getScaleY() which might suit your needs.
If there is not an existing solution, can anyone suggest a good approach to take?
Design a different UI optimized for smaller screens.
Or, use a ScrollView (or HorizontalScrollView) and use bigger widgets (effectively pre-zooming your content).
You can try to implement your own pseudo-zoom by changing the text size and button sizes based upon user input (e.g., options menus to zoom in/out), but I'm not sure how well that will work.