3

I Cant See Contents of first few rows of my ListView when Keyboard is Visible.

I have spent the day trying various layout code out there as well as my own to fix this and I now understand the issue a little more to help somebody to help me solve it.

The issue is if i specify the height of the listview (or its container) to fill_parent then that is making android think that the bottom of the listview (bottom of the screen) is the part to show above the keyboard, even though there is no actual contents yet to show there. I cant event scoll up to the beginning of my list contents for some reason. Specifying just wrap content just shows a small area shwoing the list as expected.

Here's my latest layout code (all attempts produce the same issue)

 <RelativeLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:id="@+id/RelativeLayoutchat"
 >
<LinearLayout
android:orientation="horizontal"
android:gravity ="clip_horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true">
</LinearLayout>
<LinearLayout  android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
    android:id="@+id/MessagesListView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:transcriptMode="alwaysScroll"
    android:divider="#000000"
    android:clickable="false"
    android:layout_weight="9"
    android:cacheColorHint="#00000000"/>
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_weight="1"
    style="@android:style/ButtonBar"
    android:gravity="center"
    android:paddingLeft="3dip"
    android:paddingTop="3dip"
    android:paddingRight="3dip">
    <EditText
        android:id="@+id/msgBox"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:maxLines="5"
        android:enabled="true"
        android:textSize="17sp"
        android:maxLength="150"/>
    <Button
        android:id="@+id/sendbutton"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="send"
        android:layout_weight="4"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

Any help is really appreciated.

  • I also have android:windowSoftInputMode="adjustPan" in the relevent activity tag. – Arial Buckley Jun 30 '12 at 21:09
  • I have solved this issue but created another issue. The problem was having the activity as fullscreen. I removed the code and I can scroll to the very top of the list when keyboard is shown.. but I really want to have fullscreen throughout my app so anybody understand what the solution is please? – Arial Buckley Jun 30 '12 at 23:37

1 Answers1

2

I had the same issue and solved this with the below code.

in your activity:

mylistview.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
mylistview.setStackFromBottom(true);

or in xml file for

android:stackFromBottom="true"
    android:transcriptMode="normal"

and keeping the adjustResize for activity in manifest file.

<activity .... android:windowSoftInputMode="stateHidden|adjustResize" ..../>

Source: Push Listview when keyboard appears without adjustPan

Community
  • 1
  • 1
Noundla Sandeep
  • 3,334
  • 5
  • 29
  • 56
  • This seems to only work at the activity layer, still leaves us fragment users in the dust – em_ Jul 30 '18 at 21:15