Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
207 views
in Technique[技术] by (71.8m points)

android - ListView items hide behind the EditText. Need whatsapp like chat activity

I am having trouble in my layout implementation. Whenever I click on the edittext the softinput keyboard appears and hides the listview items, what i need is that whenever soft keyboard pops up and if the listview's last item is visible, it should be brought above the edit text, if its not visible, the list should remain the way it is (the same way it is in whatsapp), heres my layout code

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

I have used window:softInputMode as adjustResize in my manifest for the activity, since using adjustPan hides the editText behind soft keyboard in some cases. Please suggest how I can achieve this. Thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Got the solution....

mListView.setTransctiptMode(ListView.TRANSCRIPT_MODE_NORMAL);

did the trick :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...