簡體   English   中英

單擊時鍵盤按Edittext內容

[英]Keyboard pushing edittext content when clicking

當我開始寫東西時,鍵盤會向上推edittext的內容,已經在AndroidManifest中添加了android:windowSoftInputMode="adjustResize" 請提供此問題的解決方案。

這是我的代碼。

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

似乎您在鍵盤上使用了Adjust_resize,如果您不希望調整大小,則視圖將被“調整大小”以適合您的視圖(我的意思是布局),請更改為AdjustPan

FYR 在Android中AdjustResize和AdjustPan之間的區別?

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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM