1

This is the screen without the keyboard:

https://i.stack.imgur.com/YOnMf.png

But when I click on the EditText and the keyboard goes up, the header messes up and disappears because it goes up too:

https://i.stack.imgur.com/zyJ3j.png

This is the code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".SecondActivity"
android:background="@color/white">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="55dp"
    android:id="@+id/abs"
    android:orientation="horizontal"
    android:layout_alignParentTop="true"
    android:gravity="center">

        <ImageView
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:id="@+id/btnVoltar"
            android:src="@drawable/inochat"
            android:layout_marginLeft="3dp"/>

        <ImageView
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:id="@+id/usu"
            android:src="@drawable/usuario"
            android:layout_alignParentRight="true"
            android:background="@drawable/foto"
            android:layout_marginRight="2dp"
            android:layout_marginTop="3dp"/>

        <TextView
            android:layout_width="fill_parent"
            android:layout_toLeftOf="@+id/addfavorito"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="Nome"
            android:id="@+id/nomeoutro"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@+id/btnVoltar"
            android:layout_toEndOf="@+id/btnVoltar"
            android:textColor="#000000"
            android:textSize="15dp"
            android:layout_marginLeft="5dp"/>

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:src="@drawable/traco"
            android:layout_alignParentBottom="true"/>

        <ImageButton
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:id="@+id/addfavorito"
            android:layout_centerVertical="true"
            android:layout_toStartOf="@+id/usu"
            android:src="@drawable/fav"/>
</RelativeLayout>

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipe_refresh_layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/llMsgCompose"
    android:layout_below="@+id/abs">

    <ListView
        android:isScrollContainer="false"
        android:layout_above="@+id/llMsgCompose"
        android:id="@+id/txtMensagens"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@null"
        android:divider="@null"
        android:transcriptMode="alwaysScroll">
    </ListView>

</android.support.v4.widget.SwipeRefreshLayout>

<RelativeLayout
    android:id="@+id/llMsgCompose"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:background="@color/white"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="1dp"
    android:gravity="center">

    <EditText
        android:id="@+id/txtMensagem"
        android:layout_width="50dp"
        android:layout_height="fill_parent"
        android:background="@color/bg_msg_input"
        android:textColor="@color/text_msg_input"
        android:paddingLeft="6dp"
        android:paddingRight="6dp"
        android:inputType="text"

        android:layout_alignParentRight="true"
        android:layout_toRightOf="@+id/icone"/>

    <ImageView
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:id="@+id/icone"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:background="@color/bg_msg_input"
        android:src="@drawable/msg"/>
</RelativeLayout>

</RelativeLayout>
  • try adding android:windowSoftInputMode="adjustResize" in your activity tag in manifest or android:windowSoftInputMode="adjustPan" – Aakash Oct 02 '15 at 17:52

2 Answers2

1

Try adding the following for this activity in Manifest:

android:windowSoftInputMode="adjustPan"

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.

Also, Refer to this blog,

http://android-developers.blogspot.com/2009/04/updating-applications-for-on-screen.html

Something like,

 <activity
   android:label="@string/app_name"
   android:name=".MainActivity" android:windowSoftInputMode="adjustNothing">
   <intent-filter>
     <action android:name="android.intent.action.MAIN" />
     <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
 </activity>
dhun
  • 643
  • 7
  • 13
0

Add this line in your onCreate():

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

this is what it looked like before: https://i.stack.imgur.com/BQOUV.jpg

after: https://i.stack.imgur.com/3ohtZ.jpg

Haider Malik
  • 1,581
  • 1
  • 20
  • 23