2016-08-01 152 views
0

所以我有一個EditText在用戶輸入屏幕的底部,當我點擊它時,鍵盤彈出並且它將其移動,但問題在於它如何移動。 EditText不是用鍵盤移動,而是鍵盤會顯示,半秒鐘後,EditText會卡入到位。當我關閉鍵盤時,EditText在返回到原始大小之前保持半秒的擴展大小。當鍵盤彈出時向上移動佈局

問題是,是否可以平滑過渡?

不確定這是否會影響結果,但它在Fragment之內。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:backgroundTint="#c1c1c1"> 

    <ListView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/ListViewChat" 
     android:layout_alignParentLeft="false" 
     android:layout_alignParentStart="false" 
     android:dividerHeight="1dp" 
     android:layout_alignParentRight="false" 
     android:layout_alignParentEnd="false" 
     android:layout_below="@+id/tabs" 
     android:layout_above="@+id/relativeLayout4" /> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/transparent" 
     android:id="@+id/relativeLayout4" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true"> 

     <EditText 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/editTextMessage" 
      android:hint="Enter a message..." 
      android:background="@android:color/transparent" 
      android:layout_alignBottom="@+id/buttonSend" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:layout_alignParentTop="true" 
      android:layout_toLeftOf="@+id/buttonSend" 
      android:layout_toStartOf="@+id/buttonSend" 
      android:layout_marginLeft="20dp" 
      android:layout_marginTop="10dp" 
      android:layout_marginBottom="10dp" 
      android:maxLength="120" 
      android:singleLine="true"/> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Send" 
      android:id="@+id/buttonSend" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentEnd="true" 
      android:background="@null" /> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/imageView5" 
      android:src="@drawable/linebreak2px" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" /> 
    </RelativeLayout> 

</RelativeLayout> 
+0

嘗試在父容器中設置'android:animateLayoutChanges =「true」'。這應該有效地平滑突然的變化。 – Mithun

回答

0

嘗試設置

android:windowSoftInputMode="adjustResize" 

你的AndroidManifest.xml中,您的活動中,讓我知道,如果它

+0

不幸的是,在軟鍵盤完全出現之後'EditText'被鎖定到位,並且在完全離開屏幕後被鍵盤鎖定在原始位置。 – QQClientServer

0

嘗試下面的AndroidManifest.xml在您acivity在聲明你有你正在

android:windowSoftInputMode="adjustPan" 

的片段,讓我知道,如果它的工作原理