Anthony
Anthony

Reputation: 3074

Android Scroll Container - Can't see EditText when focused

I have a small issue with a android layout file, when the user touches a EditText the keyboard comes up but hides the edittext behind the keyboard... This is because I keep the logon button above the keyboard...

My XML file looks like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#ffffff"
                android:clickable="true"
                android:orientation="vertical">


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:isScrollContainer="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">


            <LinearLayout
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:layout_weight="5"
                android:orientation="vertical"
                android:paddingLeft="25dp"
                android:paddingRight="25dp">

                <ImageView
                    android:layout_width="fill_parent"
                    android:layout_height="100dp"
                    android:contentDescription="logo"
                    android:paddingTop="10dp"
                    android:src="@drawable/ic_launcher"/>


                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:text="Driver ID"
                    android:textColor="@color/red"/>

                <EditText
                    android:id="@+id/driver_id"
                    android:layout_width="match_parent"
                    android:layout_height="35dp"
                    android:background="@drawable/rounded_text"
                    android:hint="Only digits allowed"
                    android:inputType="number"
                    android:text="1"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:text="Registration"
                    android:textColor="@color/red"/>

                <EditText
                    android:id="@+id/registration"
                    android:layout_width="match_parent"
                    android:layout_height="35dp"
                    android:background="@drawable/rounded_text"
                    android:hint="Only letters and digits allowed"
                    android:inputType="text|textCapCharacters|textNoSuggestions"
                    android:text="KV61 YVZ"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:text="Pin"
                    android:textColor="@color/red"/>

                <EditText
                    android:id="@+id/pin"
                    android:layout_width="match_parent"
                    android:layout_height="35dp"
                    android:background="@drawable/rounded_text"
                    android:hint="Please Enter your pin"
                    android:imeOptions="actionSend"
                    android:inputType="numberPassword"
                    android:text="9999"/>

            </LinearLayout>


        </LinearLayout>

    </ScrollView>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:paddingTop="10dp">

        <Button
            android:id="@+id/logon_btn"
            android:layout_width="match_parent"
            android:layout_height="55dp"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:background="@color/green"
            android:text="Log On"
            android:textColor="@color/black"
            android:textSize="21dp"
            android:textStyle="bold"/>

    </RelativeLayout>

</RelativeLayout>

Here are some screenshots: Keyboard not showing: Keyboard not showing

Keyboard showing: Keyboard showing

I would like it so that when the user touches the "pin" EditText that they can see what they are typing. Thanks in advance :)

I have tried the fix mentioned below:

This does not work. Any other tips? Thanks :)

Upvotes: 2

Views: 880

Answers (2)

Anthony
Anthony

Reputation: 3074

Balu was semi correct with his answer

android:windowSoftInputMode="adjustPan" in the activity tag of the AndroidManifest.xml

but I also needed to add

 android:isScrollContainer="true"

to my scrollview.

  <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/backlayout"
        android:isScrollContainer="true"
        android:orientation="vertical"
        android:paddingTop="10dp">

 </ScrollView>

Upvotes: 2

balu b
balu b

Reputation: 272

in Manifest,you need to set windowSoftInputMode as adjustPan for activity

<activity android:name="your activity"
           android:windowSoftInputMode="adjustPan">
 </activity>

Upvotes: 3

Related Questions