2015-03-20 3 views
-2

У меня возникли проблемы с моей реализацией макета. Всякий раз, когда я нажимаю на edittext, появляется клавиатура softinput и скрывает элементы списка, мне нужно, чтобы всякий раз, когда появляется мягкая клавиатура, и если последний элемент списка видна, она должна быть поднята над текстом редактирования, если его не видно, список должен оставаться так, как это (так же, как это в WhatsApp), Херес моего макета кодЭлементы ListView скрываются за EditText. Нужна whatsapp как активность чата

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/bg_other" > 

<include 
    android:id="@+id/actionbar_toolbar" 
    layout="@layout/toolbar" /> 

<ListView 
    android:id="@+id/lv_listView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/line_separator" 
    android:layout_below="@+id/actionbar_toolbar" 
    android:clipToPadding="false" 
    android:divider="@android:color/transparent" 
    android:dividerHeight="12dp" 
    android:paddingBottom="12dp" 
    android:scrollbars="none" 
    android:stackFromBottom="true" > 
</ListView> 

<View 
    android:id="@+id/line_separator" 
    android:layout_width="match_parent" 
    android:layout_height="1dp" 
    android:layout_marginLeft="10dp" 
    android:layout_marginRight="10dp" 
    android:layout_above="@+id/ll_editText" 
    android:background="#1F000000"/> 

<LinearLayout 
    android:id="@+id/ll_editText" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:orientation="horizontal" 
    android:padding="8dp" > 

    <EditText 
     android:id="@+id/et_editText" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_vertical" 
     android:layout_weight="1" 
     android:hint="@string/message_hint" 
     android:textCursorDrawable="@drawable/cursor_color" 
     android:maxLines="4" /> 

    <View 
     android:layout_width="1dp" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="5dp" 
     android:background="#1F000000"/> 

    <Button 
     android:id="@+id/btn_Button_send" 
     android:layout_width="48dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="center_vertical" 
     android:text="@string/cherry_send" 
     android:textColor="@color/orange" 
     android:textSize="24sp" 
     android:background="@android:color/transparent" /> 
</LinearLayout> 

<Button 
    android:id="@+id/btn_Button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/ll_editText" 
    android:layout_alignParentRight="true" 
    android:layout_marginBottom="5dp" 
    android:layout_marginRight="5dp" 
    android:background="#A0000000" 
    android:paddingLeft="2dp" 
    android:paddingRight="2dp" 
    android:text="2 new messages" 
    android:textColor="@android:color/white" 
    android:textSize="14sp" 
    android:visibility="gone" /> 

</RelativeLayout> 

Я использовал окно: softInputMode, как adjustResize в моем манифесте деятельности, поскольку использование adjustPan скрывает EditText позади мягкая клавиатура в некоторых случаях. Просьба предложить, как я могу это достичь. Заранее спасибо

ответ

1

Got решение ....

mListView.setTransctiptMode(ListView.TRANSCRIPT_MODE_NORMAL); 

сделал трюк :)

0

Попробуйте LinearLayou что-то вроде этого:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <ListView 
     android:id="@+id/lv_listView" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:clipToPadding="false" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="12dp" 
     android:paddingBottom="12dp" 
     android:scrollbars="none" 
     android:stackFromBottom="true" > 
    </ListView> 

    <View 
     android:id="@+id/line_separator" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:background="#1F000000" /> 

    <LinearLayout 
     android:id="@+id/ll_editText" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:padding="8dp" > 

     <EditText 
      android:id="@+id/et_editText" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:layout_weight="1" 
      android:hint="text" 
      android:maxLines="4" /> 

     <View 
      android:layout_width="1dp" 
      android:layout_height="match_parent" 
      android:layout_marginLeft="5dp" 
      android:background="#1F000000" /> 

     <Button 
      android:id="@+id/btn_Button_send" 
      android:layout_width="48dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="center_vertical" 
      android:background="@android:color/transparent" 
      android:textSize="24sp" /> 
    </LinearLayout> 

    <Button 
     android:id="@+id/btn_Button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="5dp" 
     android:layout_marginRight="5dp" 
     android:background="#A0000000" 
     android:paddingLeft="2dp" 
     android:paddingRight="2dp" 
     android:text="2 new messages" 
     android:textColor="@android:color/white" 
     android:textSize="14sp" 
     android:visibility="gone" /> 

</LinearLayout> 
+0

Эй спасибо за комментирование .... Я уже пробовал использовать линейный макет, но не использовал ..... текст редактирования по-прежнему попадает поверх списка. Я чувствую, что это может быть из-за кнопки btn_Button, которую я использую, чтобы показывать новые сообщения, которые появляются над редактировать текст линейный макет ...... c ant найти способ решить эту проблему –

Смежные вопросы