Android Keyboard Hides Edittext

Android - Keyboard hides editText

Remove adjustPan value for android:windowSoftInputMode in your AndroidManifest.xml.

<activity
...
android:windowSoftInputMode="adjustResize|stateHidden" >
</activity>

adjustPan value is explained on the official Android website as:

The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

Source: http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

Keyboard hides edit text

Use this same code with ScrollView:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:paddingTop="15dp"
tools:context="com.example.lenovo.memcreator.fragments.CreateMemoryFragment">

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

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="vertical"
tools:ignore="UselessParent">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:gravity="center"
android:text="@string/create_a_new_memory"
android:textSize="20sp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
android:weightSum="8"
tools:ignore="DisableBaselineAlignment">

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="@string/memory_name"
android:textSize="17sp" />

<EditText
android:id="@+id/memory_name"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginLeft="15dp"
android:layout_weight="5"
android:background="@drawable/edit_text_border"
android:gravity="top"
android:inputType="textMultiLine"
android:padding="5dp"
android:scrollbars="vertical"
android:textColor="#c2000000"
android:textCursorDrawable="@null"
android:textSize="16sp"
tools:ignore="RtlHardcoded" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="220dp"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:weightSum="8"
tools:ignore="DisableBaselineAlignment">

<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_weight="3"
android:orientation="vertical"
android:weightSum="10">

<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6"
android:contentDescription=""
android:scaleType="centerCrop"
android:src="@drawable/no_image"
tools:ignore="ContentDescription,NestedWeights" />

<Button
android:id="@+id/btn_add_image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:text="@string/browse"
android:textAllCaps="false" />

<Button
android:id="@+id/btn_capture_image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:text="@string/capture"
android:textAllCaps="false" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="220dp"
android:layout_marginLeft="15dp"
android:layout_weight="5"
android:orientation="vertical"
tools:ignore="RtlHardcoded">

<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="@string/post_mem"
android:textSize="17sp" />

<EditText
android:id="@+id/memory_text"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@drawable/edit_text_border"
android:gravity="top"
android:inputType="textMultiLine"
android:minLines="6"
android:padding="5dp"
android:scrollbars="vertical"
android:textColor="#c2000000"
android:textCursorDrawable="@null"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>

<Button
android:id="@+id/btn_create_memory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@color/colorPrimary"
android:text="@string/create_memory"
android:textAllCaps="false"
android:textColor="#ffffff" />
</LinearLayout>
</ScrollView>

Android soft keyboard hides edit text field with windowSoftInputMode set

I got this working fully with XML. If you are looking to:

  • Not have the soft keyboard come up when an activity starts
  • Not have the soft keyboard hide any editText on the page (even with fragments)

Enter the following in your AndroidManifest.xml file for the activity that you wish to do the above to.

android:windowSoftInputMode="stateHidden|adjustPan"

Android soft keyboard covers EditText field

Are you asking how to control what is visible when the soft keyboard opens? You might want to play with the windowSoftInputMode. See developer docs for more discussion.

Android: Keyboard hiding EditText in Fragment [Material]

I have found the solution to the problem: i was using com.google.android.material:material:1.2.0-alpha02 apparently it seems to have problems with the auto-adjustment of the screen.
Changing with com.google.android.material:material:1.2.0-alpha06 it worked properly.



Related Topics



Leave a reply



Submit