Move screen up when keyboard appears to certain px or dp - android

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"

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.

Adjust height according to keyboard

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.

Move an element in relative layout to absolute edge of the screen

Is it possible to move a button or any other element in relative layout to the absolute edge of the sreen? If I drag a certain element to the edge of the layout, eclipse will automatically place it a few dp away from the edge. It'll basically just create a small space between a button and the end of the creen. Is it possible to bypass that?
I know buttons aren't meant to be that close to the edge of the screen anyway, but I need it for a certain thing.
The normal button has a little padding by default, because the buttons backgroundimage is a 9-patch image with padding left, right and on bottom. That's why you see the space between button and screen.
To solve this you can use a custom button. For example change the backgroundimage of button like this android:background="#drawable/image".

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.

hide a portion of button under textedit

I am trying to achieve exactly something like this
- a text view on left and a button to its right
- Button should be wrap_text
- textedit should occupy the remaining space
If you carefully see the image in the image the buttons left curved border are hiding under the text view.
I am using relative layout to adjust the button height according to this
How to get a button's height to match another element's height?
But I am unable to hide the left portion of the button.
Actually the Button isn't hidden under the EditText.
They used custom background for that button, which is 9 patch png image. You can achieve this by providing your 9 patch images for both EditText and Button with 0 margin between them.
Here is a nice tutorial about using 9 patch png.
Another post to consider is Buttons with (niceley) stretched background.
add android:layout_marginLeft="-10dp" to the button

Categories

Resources