1

In my app, there is a login and password field near the middle of the screen. I have this in the manifest

android:windowSoftInputMode="adjustResize|stateHidden"

So that the fields are still visible when the keyboard is showing. But the problem is, there is a textview that is bottom aligned, and when the keyboard shows, this view overlaps with the login button under the username/password fields, is there a way, so set that textview field to not be affected by the adjestResize?

Thanks.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/credentailsLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background_home"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".ActivityHome" >

    <ImageView
        android:id="@+id/imageLogo"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/username"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="50dp"
        android:layout_marginTop="10dp"
        android:scaleType="centerInside"
        android:contentDescription="@+strings/logoimage"
        android:src="@drawable/logo_2_scale" />

    <EditText
        android:id="@+id/username"
        android:layout_width="480dp"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginBottom="10dp"
        android:layout_centerInParent="true"
        android:background="@drawable/bg_edit_text"
        android:gravity="center"
        android:hint="@string/login_username"
        android:inputType="textEmailAddress"
        android:text="@string/DEBUG_login_username"
        android:textColor="#000000" >
    </EditText>

    <EditText
        android:id="@+id/password"
        android:layout_width="480dp"
        android:layout_height="wrap_content"
        android:layout_below="@+id/username"
        android:layout_marginBottom="10dp"
        android:layout_centerInParent="true"
        android:background="@drawable/bg_edit_text"
        android:gravity="center"
        android:hint="@string/login_password"
        android:inputType="textPassword"
        android:text="@string/DEBUG_login_password"
        android:textColor="#000000" />

    <Button
        android:id="@+id/logInMode"
        style="@style/loginButtonStyle"
        android:layout_width="480dp"
        android:layout_height="43dp"
        android:layout_below="@+id/password"
        android:layout_centerInParent="true"
        android:background="@drawable/button_selector"
        android:gravity="center"
        android:onClick="ValidateLogin"
        android:text="@string/loginonline" />

    <TextView
        android:id="@+id/advancedMenu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_gravity="bottom"
        android:background="@drawable/advmenu_button_selector"
        android:clickable="true"
        android:gravity="center"
        android:onClick="ShowAdvancedMenu"
        android:paddingBottom="3dp"
        android:paddingLeft="3dp"
        android:paddingRight="3dp"
        android:paddingTop="2dp"
        android:text="@string/advancedmenu"
        android:textColor="#FFFFFF"
        android:textSize="17sp" />
</RelativeLayout>
omega
  • 40,311
  • 81
  • 251
  • 474

1 Answers1

0

EDIT:
Apparently a member of the Android team said there is no direct way to do this. I searched for "android check if keyboard is visible" on Google and got the following answered question: How do I Detect if Software Keyboard is Visible on Android Device?

According to the linked answer, you can detect it indirectly by checking if the window size changed in #onMeasure. See How to check visibility of software keyboard in Android?

Community
  • 1
  • 1
Aftab Safdar
  • 653
  • 5
  • 19
  • did you add `android:configChanges="orientation|keyboardHidden"` to the `activity` in `AndroidManifest`? Check the link i posted for OnConfigChanged – Aftab Safdar Dec 01 '13 at 23:51
  • Apparently a member of the Android team said there is no direct way to do this. I searched for "android check if keyboard is visible" on Google and got http://stackoverflow.com/questions/4745988/how-do-i-detect-if-software-keyboard-is-visible-on-android-device
    According to the linked answer, you can detect it indirectly by checking if the window size changed in #onMeasure. See http://stackoverflow.com/questions/2150078/android-is-software-keyboard-shown
    – Aftab Safdar Dec 02 '13 at 02:09