Search code examples
androidandroid-edittextandroid-softkeyboardandroid-scrollview

SoftKeyboard override editText


I have scrollview with some elements, and one of them - edit text, near the bottom of layout. when this editText request focus by click - soft keyboard is opened and override that editText fild, so user cant see what he typing...

any ideas why it happen and how to fix it?

here is my code manifest:

<activity
            android:name=".acitivity.TransferActivity"
            android:label="@string/title_activity_transfer"
            android:theme="@style/AppTheme.NoActionBar"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize">
        </activity>

here is activity xml:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_transfer"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

    <fragment
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/container_transfer_activity"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:layout="@layout/fragment_transfer" />


</LinearLayout>

here is fragment xml:

 <ScrollView
                android:id="@+id/transfer_scroller"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/blue_500"
                xmlns:android="http://schemas.android.com/apk/res/android">
               <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >
                        //some code here
               </LinearLayout>
               <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >
                        //some code here
               </LinearLayout>
               <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >
                        <EditText
                            android:id="@+id/et_transfer_p1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center_horizontal"
                            android:inputType="number"
                            android:textColor="@color/gray_400"
                            android:textSize="@dimen/font_main_2" >
                        </EditText>
               </LinearLayout>
               </LinearLayout>
 </ScrollView>

Solution

  • Try this..

    android:windowSoftInputMode="adjustPan"