简体   繁体   中英

Keyboard pushing edittext content when clicking

Keyboard pushing content of edittext up when I start writing something , already add android:windowSoftInputMode="adjustResize" in AndroidManifest. Please provide solution for this issue.

Here is my code.

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.mouad.fixmyphone.fragment.SendUsFragment"
android:background="#ffff">

<!-- TODO: Update blank fragment layout -->


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="20dp">
    <View
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:layout_below="@id/idtitle"
        android:background="#000000" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="E-mail :"
        android:textSize="20sp"
        android:textStyle="bold"
        android:textColor="#1A237E"
        android:layout_marginTop="90sp"
        android:id="@+id/textView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <Button
        android:text="SEND"
        android:textStyle="bold"
        android:layout_width="130sp"
        android:layout_height="wrap_content"
        android:id="@+id/sendbtn"
        android:textColor="#ffffff"
        android:background="@drawable/roundshapebtn"
        android:layout_marginTop="17dp"
        android:layout_below="@+id/msgtext"
        android:layout_centerHorizontal="true" />

    <EditText
        android:background="@drawable/rounded_edittext"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Your Problem in Short"
        android:textStyle="bold"
        android:id="@+id/msgtext"
        android:maxLength="80"
        android:maxLines="2"
        android:inputType="textMultiLine"
        android:layout_below="@+id/textmsgview"
        android:layout_alignParentLeft="true"
        android:drawableLeft="@drawable/ic_pb"
        android:layout_alignParentStart="true"
        android:drawablePadding="20dp"
        android:paddingLeft="1dp"
        android:paddingRight="12dp"
        android:paddingTop="12dp"
        android:paddingBottom="12dp"
        android:layout_marginTop="17dp"/>

    <EditText
        android:background="@drawable/rounded_edittext"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Your E-mail . . ."
        android:textStyle="bold"
        android:id="@+id/emailtext"
        android:inputType="textEmailAddress"
        android:drawableLeft="@drawable/ic_email"
        android:drawablePadding="20dp"
        android:paddingLeft="1dp"
        android:paddingRight="12dp"
        android:paddingTop="12dp"
        android:paddingBottom="12dp"
        android:layout_below="@+id/textView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginTop="17dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Tell us your problem :"
        android:textSize="20sp"
        android:textStyle="bold"
        android:textColor="#1A237E"
        android:layout_marginTop="20dp"
        android:id="@+id/textmsgview"
        android:layout_below="@+id/emailtext"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp" />

</RelativeLayout>

it seems like you use adjust_resize for the keyboard, the view will be "resized" to fit your view(i mean layout) if you dont want any resize, change to adjustPan

FYR Difference between adjustResize and adjustPan in android?

Problem solved with ScrollView

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout 
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   xmlns:android="http://schemas.android.com/apk/res/android">
   <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <LinearLayout 
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:orientation="vertical">
              <!-- Content here -->
        </LinearLayout>
   </ScrollView>
 </LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM