Adjust height according to keyboard - android

I'm trying to design a layout similar to LinkedIn screen for sharing an update.
When you enter the screen for the first time the layout is split something like this:
half the screen is an edittext
half the screen is a gallery of images with a bar above the gallery
Now when I click the edittext - the keyboard comes up and it's just as high as the gallery, leaving the bar with the camera icon visible.
How did they design this layout so that the keyboard height is kinda the same as the gallery height?

In fact every keyboard can have different height, so to achieve this you should resize your activity to fit current 'height' when keyboard is shown status.
Tricky part is, android doesn't provides you that current status is keyboard shown status or not, so you should manage this status smart(One tip can be comparing curent height or height/width ratio to check it's resized or not by keyboard.

Related

Codename One Keyboard Cover Image

I have an Android application with a text field. When I start typing, the keyboard pushes the background image upwards.
I want the image to stay in place and the keyboard to cover it, instead.
Changing the layout to BoxLayout or BorderLayout does not have any effect on the position of the background image, neither does changing scrollable:
container.setScrollableY(false);
form.setScrollableY(false);
How would I achieve keeping the image in place?
One other thing I was unable to figure out was accessing the form with the cursor already in the TextField and the keyboard visible, setting:
textField.requestFocus();
But that also does not have the desired effect.
Any help would be appreciated.
In addition to Shai's answer, you could try placing the TextField parent container in the north of a BorderLayout container and the image container in the center. This could somehow enforce the keyboard to slide over the image in the center.
To answer the part of TextField editing when the form is shown, add below to the TextField form
form.setEditOnShow(textField);
If you already have some text in the TextField, you might want to set below to place the cursor at the end:
CN.callSerially(() -> {
textField.setCursorPosition(textField.getText().length());
form.repaint(); // optional form repainting
});
Text fields must be in a scrollable parent.
If the image and the text field are in the same container and the text field is above the image you might get something closer to the second image. On iOS the scroll region is increased to accommodate the virtual keyboard, on Android the screen is resized to accommodate it.
This can lead to nuanced behavior difference as the size of the screen adapts.

Move screen up when keyboard appears to certain px or dp

I have editText on the top screen and some button on bottom of screen, so I need to make it so and edit text and button will visible when keyboard appears. I've tried to use android:windowSoftInputMode, but I still can see just part of button. How to move keyboard on certain px or dp value or bind it to certain view element?
Have you tried this?
android:windowSoftInputMode="adjustPan|adjustResize"

Floating Action Button changes size on multi-window

I've noticed when using the design library's Floating Action Button that when the app is put in multi-window mode, the FAB is automatically resized to its "mini" size. Other apps such as Gmail share the same behaviour.
As opposed to that, my own UI elements and buttons don't change size. I set a fixed dp size for them, and they stay with that same size.
Is there any design recommendation to provide smaller UI elements when the app is in multi-window mode? Should one listen for app size changes and resize buttons depending on it? Or is this behaviour only recommended for the FAB button?

Determining a mobile devices maximum browser height (when the address bar is not showing)

I have been working on this for days now. Looking through countless articles and trying a lot of different ideas that I have had.
All I am looking to do is have a background image or element that is 100% of the browser height.
The problem is that whenever the address bar shows and hides the available space changes and the picture resizes causing an annoying jump.
I am using a full screen image slider called maximage 2 (http://www.aaronvanderzwan.com/maximage/)
First I tried to make the html or body containers aligned to the top and 120% high so that when the address bar goes away it will still cover. But the image still resizes as 120% of the new size is still different.
I have also been trying to store the original browser height and then adding to that number to compensate for the address bar and resizing the slider to the new size.
I was thinking in the way of using device aspect ratios and taking into account something that stays fixed such as the width, but this would vary from device to device and not be reliable.
Does anyone know of any simple and clean ways to simply cover the background of a mobile device with an image slider without using a percentage that will resize?
I had the same problem. The solution was to set the background hight to window height via jQuery and block the resize event while the scroll event is active.
That way you can scroll let the address bar disappear and have no nasty resize jump happen.
https://stackoverflow.com/a/31546432/1612318

Available height for softkeys in landscape

For an InputMethodService in landscape Android automatically presents a text box that shows the text entered via the soft keys. How is it possible to get that text box height, so I can calculate the available screen height in landscape?
Thanks!
Found it!
It works the other way around: I can use whatever portion of the screen height I want, then Android occupies the remaining space with the text box.

Categories

Resources