7

My layout looks like this:

<LinearLayout>
  <RelativeLayout>
    Some Image and Text as Title
  </RelativeLayout>
  <RelativeLayout>
    <LinearLayout>
      <ListView>
        My message List
      </ListView>
    </LinearLayout>
    <RelativeLayout>
      Edit Box and Send Button
    </RelativeLayout>
  </RelativeLayout>
</LinearLayout>

I explicitly set the current selection to the last item (newest) of the list when showing.

When not entering text in the Edit box at the bottom, the screen looks like this:

Top Title
  List Item 8
  List Item 7
  ...
  List Item 2
  List Item 1
  Bottom Edit box and Send Button

When I click on the Edit box to type my message, the screen looks like this:

Top Title
  List Item 8
  ...
  List Item 5
  Bottom Edit Box and Send Button
  Keyboard

What I really want is:

Top Title
  List Item 4
  ...
  List Item 1
  Bottom Edit Box and Send Button
  Keyboard

Can someone help me please?

evilone
  • 22,410
  • 7
  • 80
  • 107
radium22
  • 155
  • 1
  • 9

2 Answers2

11

I found the answer here.

Basically just extend ListView with your custom class, override the onSizeChanged() method to setSelection(getCount());

This seems to be the best solution, and it appears Google Voice uses the same tactic (because if you're at the top of the chat list, then rotate the screen, it puts you back at the bottom).

Also remember that android:windowSoftInputMode="adjustResize" is present instead of adjustPan in your activity's tags in your manifest.

Community
  • 1
  • 1
Weston
  • 1,882
  • 1
  • 20
  • 26
2

Did you try this?

You would need to use setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL) and setStackFromBottom(true) in your list. Hope it helps, it worked for me!

Community
  • 1
  • 1