Android - Soft Keyboard pushes layout of my activity out of screen

后端 未结 3 812
醉话见心
醉话见心 2021-01-01 11:24

My activity\'s layout is as shown below.



        
相关标签:
3条回答
  • 2021-01-01 11:34

    @Raj If you are working with a tabbed application you have to add

    android:windowSoftInputMode="adjustPan"

    on the Activity where you are adding the tabs, this would most probably be your launcher activity.

    Here is a snippet from my code

    <activity
       android:label="@string/app_name"
       android:name=".MainActivity" android:windowSoftInputMode="adjustPan">
       <intent-filter >
         <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.LAUNCHER" />
       </intent-filter>
    

    0 讨论(0)
  • 2021-01-01 11:40

    Try adding the following for your activity in Manifest:

    android:windowSoftInputMode="adjustPan"
    
    0 讨论(0)
  • 2021-01-01 11:43

    For those that are interested, the difference between android:windowSoftInputMode="adjustPan" and android:windowSoftInputMode="adjustResize" :

    "adjustResize"

    The activity's window is resized to make room for the soft keyboard on screen.

    "adjustPan"

    The contents of the activity's window are automatically panned so that the current focus is never blocked by the keyboard. This is so the user can 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.

    Android Documentation

    Cited link

    0 讨论(0)
提交回复
热议问题