Android Keyboard hides EditText

前端 未结 8 471
独厮守ぢ
独厮守ぢ 2020-11-29 04:58

When I try to write something in an EditText which is at the bottom of the screen, the soft keyboard hides the EditText. How can I resolve this issue? Below is my xml code.

相关标签:
8条回答
  • 2020-11-29 05:21

    Here is simple solution for Android EditText issue of hiding behind SoftKeypad. Use the code in AndroidManifest.xml file of the project module.

    <activity
            android:name="com.example.MainActivity"
            android:label="@string/activity_main"
            android:windowSoftInputMode="adjustResize|stateHidden" />
    

    This code worked for me.
    Inside the manifest file in activity tag add this attribute:

    android:windowSoftInputMode="adjustResize|stateHidden"
    

    There are more such values for this attribute (android:windowSoftInputMode) which will come as recommendation list. You can check with them also.

    0 讨论(0)
  • 2020-11-29 05:24

    I handled that by adding ScrollView around View with EditText inside.

    <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >
            // Other views
            <EditText ... />
    </ScrollView>
    

    Adding tags to Android Manifest didn't help me.

    0 讨论(0)
  • 2020-11-29 05:24

    Put this line in your application tag:-

    android:windowSoftInputMode="stateHidden|adjustPan"

    example:-

    <application
        android:name=".application.MyApplication"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:networkSecurityConfig="@xml/network_security_config"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="false"
        android:theme="@style/AppTheme"
        android:windowSoftInputMode="stateHidden|adjustPan"
        tools:ignore="GoogleAppIndexingWarning"
        tools:replace="android:supportsRtl,android:allowBackup"
        tools:targetApi="n">
    
    0 讨论(0)
  • 2020-11-29 05:26

    The solution for me was, simply, adding this to the parent layout : android:fitsSystemWindows="true"

    0 讨论(0)
  • 2020-11-29 05:29

    Declare windowSoftInputMode="adjustResize" in manifest.xml file

    <activity
            android:name=".example"
            android:theme="@style/AppTheme.NoActionBar"
            android:windowSoftInputMode="adjustResize" />
    

    provide scroll view to the xml layout file

    <RelativeLayout
             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:paddingBottom="16dp"
             android:paddingLeft="16dp"
             android:paddingRight="16dp"
             android:paddingTop="16dp"
             android:fitsSystemWindows="true">
    
    <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fillViewport="true"
            android:isScrollContainer="false">
    
       // add edittext here...
    
     </ScrollView>
     </RelativeLayout>
    
    0 讨论(0)
  • 2020-11-29 05:40

    In your manifest put this in your perticular activity:

     android:windowSoftInputMode="adjustPan" 
    
    0 讨论(0)
提交回复
热议问题