5
votes

I'm working in this login screen, and I want all fields, texts and buttons to resize when the IME is shown. I've already used the android:windowSoftInputMode="adjustResize" on androidManifest.xml, but i'm still getting some elements underneath others.

It wouldn't matter if the TextView "Cadastre Agora" (id= cadastrar) remains covered by the virtual keyboard. But, I want at least EditTexts, their TextViews and the button to be visible.

I found this unanswered question that could be an interesting approach: http: //stackoverflow.com/ questions/6484024/soft-keyboard-keep-one-view-stationary-while-moving-other

thanks for helping!

Screen without IME: http://imageshack.us/photo/my-images/138/semttulo2mr.png/

Screen with IME (TextView1 becomes hidden): http://imageshack.us/photo/my-images/404/semttulo3xw.png/

Stackoverflow is complaining about my code formatting, so i uploaded the xml file here: https ://rapidshare.com /files/1767398103/login.xml And i can't post more than 2 links, thats why I put spaces in them.

1

1 Answers

2
votes

In this case I would say your initial layout (without the keyboard showing) is already problematic. Given you are creating what appears to purely be a login screen it would be acceptable to place all your controls in the top half of the screen and have the keyboard display automatically when the user visits the page. This makes the experience faster for the user and saves you having to come up with a flexible layout.

But if you want to try and make the layout work in both views, you will need to change the spacing to be dynamic between the controls.

For example:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width = "fill_parent"
    android:layout_height = "fill_parent"
    android:orientation="vertical"
    >
    <Space 
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_weight="1">
        <!-- Username Controls here -->
    <Space 
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_weight="1">
        <!-- Password Controls here -->
    <Space 
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_weight="1">
        <!-- Login Button here -->
    <Space 
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_weight="1">
        <!-- TextView here -->
    <Space 
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_weight="1">
</LinearLayout>

For this to work properly, all of the vertical padding must be removed from your controls, with the exception of padding between the labels for the textboxes.