Umesh
Umesh

Reputation: 4256

keyboard covering part of edittext

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>

Upvotes: 0

Views: 280

Answers (4)

tiny sunlight
tiny sunlight

Reputation: 6251

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

Upvotes: 1

Vishal Thakkar
Vishal Thakkar

Reputation: 2127

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>

Upvotes: 0

Naresh Narsing
Naresh Narsing

Reputation: 785

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);

Upvotes: 0

Amarjit
Amarjit

Reputation: 4357

use android:windowSoftInputMode="adjustResize|adjustPan"

Upvotes: 1

Related Questions