4

Я пытаюсь достичь следующего вида в приложении чата. В основном есть два состояния: один с дисплеем с мягкой сенсорной клавиатурой и один без него. Извините за мое плохое представление, пожалуйста, со мной.Android Linear Layout вес и мягкая клавиатура проблема

Так что это мое начальное состояние без показа клавиатуры.

enter image description here

Это то, что происходит, когда клавиатура появляется.

enter image description here

Это то, что я пытаюсь добиться.

enter image description here

Примечание Я тока с помощью "настроить изменение размера" в качестве windowSoftInputMode. Я знаю, что использование «регулировать панорамирование» устранит проблему, но с «регулировкой панорамирования» есть две проблемы:

  1. Панель инструментов также перемещается вверх, создавая пространство для редактирования текста и клавиатуры.
  2. Редактирование текста частично покрывается клавиатурой.

Здесь нужна помощь экспертов по планированию! Спасибо заранее.

Edit:

Это то, что мой XML выглядит следующим образом:

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

    <LinearLayout 
     android:id="@+id/view_group_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@color/colorPrimaryDark" 
      android:elevation="4dip" > 

      <!-- Toolbar stuff --> 

     </android.support.v7.widget.Toolbar> 

    </LinearLayout> 

    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/bottom_bar" 
     android:layout_below="@+id/view_group_toolbar" 
     android:orientation="vertical"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="0.6"> 

      <include 
       layout="@layout/layout_that_covers_60%_of_the_screen (This is not my actual layout name :/ using it for understandability)" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/view_group_recycler_view" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="0.4" 
      android:gravity="center_vertical"> 

      <include 
       layout="@layout/layout_that_covers_40%_of_the_screen" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" /> 
     </LinearLayout> 

    </LinearLayout> 

    <RelativeLayout 
     android:id="@+id/bottom_bar" 
     android:layout_width="match_parent" 
     android:layout_height="60dip" 
     android:layout_alignParentBottom="true" 
     android:gravity="bottom" 
     android:padding="8dip" > 
      <!-- This is where my edit text resides --> 

    </RelativeLayout> 

</RelativeLayout> 
+0

хорошо структурированный вопрос вы можете разместить свой XML или корневой тег этого? –

+0

напишите свой код. –

+0

Эй, ребята, спасибо за ваш быстрый ответ, я отредактировал вопрос, включив мой XML. Это грубый эскиз того, как выглядит мой макет. – Tejas

ответ

0

Так вот что я думаю, что вы должны сделать, Используйте

windowSoftInputMode = "adjustResize" - The Главное окно операции всегда изменяется, чтобы освободить место для экранной клавиатуры. Также adjustResize сохраняет ToolBar сверху.

Попробуйте добавить оба LinearLayouts внутри NestedScrollView. Причина, по которой я говорю это, заключается в том, что содержимое вашего NestedScrollView может прокручиваться вверх.

Я думаю, что ваш макет будет выглядеть следующим образом.

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

<LinearLayout 
    android:id="@+id/view_group_toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="@color/colorPrimaryDark" 
     android:elevation="4dip" > 

     <!-- Toolbar stuff --> 

    </android.support.v7.widget.Toolbar> 

</LinearLayout> 


<NestedScrollView 
    android:layout_above="@+id/bottom_bar" 
    android:layout_below="@+id/view_group_toolbar"> 
    <LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.6"> 

     <include 
      layout="@layout/layout_that_covers_60%_of_the_screen (This is not my actual layout name :/ using it for understandability)" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/view_group_recycler_view" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.4" 
     android:gravity="center_vertical"> 

     <include 
      layout="@layout/layout_that_covers_40%_of_the_screen" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </LinearLayout> 

    </LinearLayout> 
</NestedScrollView> 
<RelativeLayout 
    android:id="@+id/bottom_bar" 
    android:layout_width="match_parent" 
    android:layout_height="60dip" 
    android:layout_alignParentBottom="true" 
    android:gravity="bottom" 
    android:padding="8dip" > 
     <!-- This is where my edit text resides --> 

</RelativeLayout> 

Позвольте мне знать, если это работает для вас.

EDIT 1: Если у вас есть RecyclerView внутри ваших макетов, вам может понадобиться установить этот атрибут для плавной прокрутки -

recyclerView.setNestedScrollingEnabled(false); 
Смежные вопросы