1

I am developing an app and I found a problem that the keyboard hides the EditText Field. Upon researching i found a solution by adding this line of code in manifest file.

android:windowSoftInputMode="adjustPan"

but now my edittext looks like this

the emoticon icon, edit text and the SEND textview are in a Linear layout. How do i show the entire linear layout above the keyboard ??

2 Answers2

1

Set android:softInputMode attribute to adjustResize in Manifest and put layout(not list item layout) inside a ScrollView.

Fathima km
  • 2,539
  • 3
  • 18
  • 26
  • sorry I didn't understand the last part "put layout(not list item layout) inside a ScrollView." – Shakil Mahmud Shanto Apr 10 '17 at 23:42
  • I mean not put the scrollview for the layout of listview if you have used listview. You may ignore that. Please put the scrollview for layout where that edittext box, send button and all come. – Fathima km Apr 11 '17 at 03:54
0

i had exact same problem with adjustPan so i use this instead..

android:windowSoftInputMode="adjustResize"

i hope your root layout is RelativeLayout.

UPDATE

try to set like this.

chat_ui.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/chat_layout"
    android:background="@color/white">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/applayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/white"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

            <TextView
                android:id="@+id/txtTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginRight="40dp"
                android:gravity="center_horizontal"
                android:text="Francis"
                android:textColor="@color/page_background"
                android:textSize="10pt" />

        </android.support.v7.widget.Toolbar>

    </android.support.design.widget.AppBarLayout>

    <ListView
        android:layout_below="@id/applayout"
        android:id="@+id/chat_list_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottomlayout"
        android:layout_marginBottom="4dp"
        android:clipToPadding="false"
        android:divider="@drawable/chat_divider"
        android:paddingBottom="4dp"
        android:paddingTop="8dp"
        android:scrollbarStyle="outsideOverlay"
        android:stackFromBottom="false"
        android:transcriptMode="normal" />

    <LinearLayout
        android:id="@+id/bottomlayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_weight="1"
            android:background="@drawable/input"
            android:minHeight="50dp"
            android:orientation="horizontal"
            android:paddingBottom="15dp"
            android:paddingLeft="12dp"
            android:paddingRight="20dp">

            <!--  <ImageView
                  android:id="@+id/emojiButton"
                  android:layout_width="24dp"
                  android:layout_height="24dp"
                  android:layout_gravity="bottom"
                  android:src="@drawable/input_emoji" />-->

            <EditText
                android:id="@+id/chat_edit_text1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:layout_marginLeft="12dp"
                android:background="@null"
                android:hint="@string/type_message"
                android:inputType="textMultiLine"
                android:singleLine="false"
                android:textColorHint="#c4c0bd"
                android:textSize="18sp" />

        </LinearLayout>

        <ImageButton
            android:id="@+id/enter_chat1"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_gravity="bottom"
            android:background="@drawable/input_circle_normal"
            app:srcCompat="@drawable/ic_send" />

    </LinearLayout>

</RelativeLayout>

and in manifest

<activity
     android:name=".activities.ChatActivity"
     android:windowSoftInputMode="stateHidden|adjustResize"
     android:screenOrientation="portrait"
     android:theme="@style/MyMaterialTheme2" />
Sagar Chavada
  • 5,169
  • 7
  • 40
  • 67