2017-12-18 9 views
0

アクティビティでsoft keyboardを開くたびに、出口のチャットボタンとrecyclerviewのようなコントロール の要素の一部が非表示になります。 私は多くのことを試しましたが、うまくいかないようです。私の活動のAndroid 'softInputMethod:adjustResize'が動作しません

  <activity 
      android:name=".ChatRoomActivity" 
      android:windowSoftInputMode="adjustResize" /> 

:私のMenifestファイルで

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


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:weightSum="4" 
     tools:ignore="UselessParent"> 


    <Button 
     android:id="@+id/exitChat" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.01" 
     android:background="@color/colorPrimaryAnonymose" 
     android:fontFamily="monospace" 
     android:text="leave chat" 
     tools:ignore="HardcodedText" /> 

    <RadioButton 
     android:id="@+id/statusBtn" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:clickable="false" 
     android:checked="true" 
     android:backgroundTint="@color/colorPrimary" 
     android:layout_weight="0.01" 
     android:text="user " 
     tools:ignore="HardcodedText" /> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/reyclerview_message_list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="3.98" 
     android:background="?attr/colorPrimary" 
     app:layout_constraintLeft_toLeftOf="parent" 
     android:isScrollContainer="false" 
     app:layout_constraintTop_toTopOf="parent"></android.support.v7.widget.RecyclerView> 



    <LinearLayout 
     android:id="@+id/layout_chatbox" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.01" 
     android:background="#ffffff" 

     android:minHeight="48dp" 
     android:orientation="horizontal" 
     android:weightSum="3"> 

     <EditText 
      android:id="@+id/chatbox" 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:layout_weight="2" 
      android:background="@android:color/transparent" 
      android:hint="write something.." 
      tools:ignore="HardcodedText,NestedWeights" /> 

     <Button 
      android:id="@+id/btn_send" 
      android:layout_width="0dp" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 

      android:background="@color/common_google_signin_btn_text_light_disabled" 
      android:clickable="true" 
      android:text="SEND" 
      android:textSize="14dp" 
      tools:ignore="HardcodedText,SpUsage" /> 
    </LinearLayout> 

</LinearLayout> 
    </RelativeLayout> 

これが私の活動のレイアウトXMLファイルです。

は、GetWindow()setSoftInputMode(WindowManager.LayoutParams .SOFT_INPUT_ADJUST_RESIZE);

ありがとうございました。

+0

android:windowSoftInputMode = "adjustResize"をアンドロイドに変更してみてください:windowSoftInputMode = "adjustPan" –

答えて

0

adjust_resizeあなたのルートビューは小さくなります。この場合、exit chatボタンを保持するLinearLayoutはandroid:layout_weight="0.01"のため非常に小さくなります。
これを防ぐには、次の操作を行う必要があります。
- ルートレイアウトはに変更され、ルートレイアウトはScrollLayout内に配置されます。
- android:layout_weightを避けてください。可能であれば、すべてのアイテムをRelativeLayout内に配置します。 RecyclerViewは、layout_aboveチャット出口ホルダ、layout_below送信ボタンです。

+0

私はレイアウトの階層をもう少し詳しく説明できますか?少し混乱します。 –

関連する問題