2016-10-11 10 views
2

私はRecyclerViewEditTextCardViewの内部に持っています。アクティビティの目的はチャットです。したがって、RecyclerViewには送受信されたすべてのメッセージが含まれ、CardViewにはユーザーがメッセージを入力する場所が含まれます。問題になると、キーボードがポップアップすると内容を上に移動する必要があります。さて、これは単純な問題ではないようです。キーボードがポップアップしたときに表示の内容をプッシュする方法は?

私はすべてのこれらの質問を試みた:

をそして、ほとんどの解決策は、android:windowSoftInputModeを変更することに帰着します。私が試したところ、adjustPanadjustResizeに切り替えました。ここに私の活動へのコードは次のとおりです。

<?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="match_parent" 
    android:layout_height="match_parent" 
    android:background="#F0F0F0" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:paddingStart="10dp" 
    android:paddingEnd="10dp" 
    tools:context="com.devpost.airway.MainActivity"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/chatView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
    </android.support.v7.widget.RecyclerView> 

    <android.support.v7.widget.CardView 
     android:layout_alignParentBottom="true" 
     android:layout_marginTop="10dp" 
     app:cardElevation="0dp" 
     app:cardCornerRadius="10dp" 
     android:layout_marginBottom="10dp" 
     android:layout_width="match_parent" 
     android:layout_height="50dp"> 

     <EditText 
      android:id="@+id/chat_input" 
      android:paddingStart="2dp" 
      android:paddingEnd="2dp" 
      android:inputType="text" 
      android:imeOptions="actionSend" 
      android:background="@null" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </android.support.v7.widget.CardView> 

</RelativeLayout> 

そしてadjustPanは非常にあいまいな方法で作業を行い、私は下のスクリーンショットを追加しました、親切に見てみましょう:

IMAGE-1

IMAGE-1

IMAGE-2

ActionBar

  • を上昇させる:

    enter image description here

    は今、明らかに画像-1と画像2から、いくつかの問題があります。

    は、任意のメソッドをオーバーライドして、物事を実装することが手動で可能です:キーボードが持ち上がったら

  • は、トランジションアニメーション
  • が追加されますそれはそう、質問があるまで

全体RecyclerViewをプッシュandroid:windowSoftInputModeが好きなように変更することを許可する以外に、親切に助けてください。

+0

adjustPan|adjustResizeはほとんど何も変更を加えないことを確認します。 @鉄人 – OBX

答えて

-1
<android.support.v7.widget.RecyclerView 
    android:id="@+id/chatView" 
    android:layout_width="match_parent" 
    android:layout_above="@+id/editorCard" 
    android:layout_height="wrap_content" /> 

<android.support.v7.widget.CardView 
    android:id="@+id/editorCard" 
    android:layout_alignParentBottom="true" 
    android:layout_marginTop="10dp" 
    app:cardElevation="0dp" 
    app:cardCornerRadius="10dp" 
    android:layout_marginBottom="10dp" 
    android:layout_width="match_parent" 
    android:layout_height="50dp"> 
<!--your editor code--> 
</android.support.v7.widget.CardView> 

wrap_contentlayout_aboveは、望ましい行動

softinputmethod

のための重要な変更は、何もしない、それは

関連する問題