0

When I click on the EditText, the keyboard pops out and covers a part of the EditText. I want the EditText to be completely visible.

I have tried adjustPan and adjustResize and they are not working. I want to do this in a fragment.

This is how it looks right now

This is how it looks right now

This is how I want it to be

This is how i want it to be

Update:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#EAEAEA"
    android:clickable="true" >

    <RelativeLayout
        android:id="@+id/header"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:background="@android:color/white" >

        <TextView
            android:id="@+id/message_header"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginLeft="15dp"
            android:layout_marginStart="15dp"
            android:gravity="center_vertical"
            android:text="@string/messages"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/black" />

        <ImageView
            android:id="@+id/close_button"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginEnd="5dp"
            android:layout_marginRight="5dp"
            android:contentDescription="@null"
            android:paddingLeft="5dp"
            android:paddingRight="5dp"
            android:src="@drawable/close" />
    </RelativeLayout>

    <ListView
        android:id="@+id/message_area"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/edit_control"
        android:layout_below="@+id/imageSmsProfile"
        android:background="#EAEAEA"
        android:divider="@null"
        android:dividerHeight="0dp"
        android:fadeScrollbars="true"
        android:overScrollHeader="#EAEAEA" >
    </ListView>

    <com.monqi.kid.custom.CustomRoundedImageView
        android:id="@+id/imageSmsProfile"
        android:layout_width="@dimen/dimen_50dp"
        android:layout_height="@dimen/dimen_50dp"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        android:background="@drawable/rounded_rectangle_shape"
        android:scaleType="centerCrop"
        app:left_bottom_corner_radius="10dip"
        app:left_top_corner_radius="10dip"
        app:right_bottom_corner_radius="10dip"
        app:right_top_corner_radius="10dip" />

    <RelativeLayout
        android:id="@+id/edit_control"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:paddingLeft="5dp"
        android:paddingRight="5dp" >

        <EditText
            android:id="@+id/input_chat_message"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginBottom="2dp"
            android:layout_marginLeft="5dp"
            android:layout_toLeftOf="@+id/button_chat_send"
            android:layout_toStartOf="@+id/button_chat_send"
            android:background="@drawable/edittext_drawable"
            android:cursorVisible="false"
            android:ems="10"
            android:inputType="textImeMultiLine"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:paddingStart="10dp" >

            <requestFocus />
        </EditText>

        <Button
            android:id="@+id/button_chat_send"
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_marginBottom="2dp"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginTop="2dp"
            android:background="@drawable/send_button"
            android:text="@string/send"
            android:textColor="@android:color/white" />
    </RelativeLayout>
</RelativeLayout>

Umesh
  • 4,406
  • 2
  • 25
  • 37

4 Answers4

1

use android:windowSoftInputMode="adjustResize|adjustPan"

Amarjit
  • 4,327
  • 2
  • 34
  • 51
  • Its is a fragment hence cannot set windowsoftinputMode. I have tried setting these flags for the activity that owns the fragment. Does not work – Umesh Feb 26 '16 at 13:39
  • @EminenT using both the adjust*** attribute value is not the correct way. – iCantC Jan 28 '20 at 09:42
1

Add android:windowSoftInputMode="adjustResize|adjustResize" in AndroidManifest and use a scrollView contains your rootView.

tiny sunlight
  • 6,231
  • 3
  • 21
  • 42
0

This worked for me when i was stuck in same kind of scenario where i have added the following line of code in my onCreate(),Hope this helps

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Naresh Narsing
  • 765
  • 6
  • 9
  • Its a fragment hence cannot set windowsoftinputMode. I have tried setting these flags for the activity that owns the fragment. Does not work – Umesh Feb 26 '16 at 13:40
  • I think all fragments of one Activity have the same behaviour as their parent Activity, but if you need different keyboard behaviour for different Fragments, you could dynamically change this property from your Fragment code like this: getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.softInputMode.SOFT_INPUT_ADJUST_PAN); – Naresh Narsing Feb 26 '16 at 13:48
0

try this xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="80dp">
</ListView>

<RelativeLayout
    android:id="@+id/form"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:orientation="vertical" >

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textMultiLine"
        android:ems="10"
        android:id="@+id/chatText"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_toLeftOf="@+id/buttonSend" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Send"
        android:id="@+id/buttonSend"
        android:layout_alignBottom="@+id/chatText"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />
</RelativeLayout>

Vishal Thakkar
  • 2,117
  • 2
  • 16
  • 33