I have a ListView
with a RelativeLayout containing an EditText
below it.
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@color/transparent"
android:dividerHeight="10sp"
android:background="@color/transparent"
android:scrollbars="none"
android:stackFromBottom="false"
android:transcriptMode="normal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/chatInput"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:focusable="true"
android:inputType="textMultiLine"
android:lines="2"
android:maxLines="5"
android:singleLine="false"
android:scrollbars="vertical"
android:focusableInTouchMode="true"
style="@style/NomadlyTheme.EditText"
android:hint="Enter text here"
android:layout_weight="0.9"
android:textColor="@color/black"/>
</RelativeLayout>
When I click on the EditText
and the soft input show up, I want the ListView
to show the same items that were displayed before the keyboard appeared, from the bottom at least:
Before soft input:
__________
| 7 |
| 8 |
| 9 | <- ListView
| 10 |
|____11____|
|__________| <- EditText
After soft input:
__________
| 9 |
| 10 |
|____11____|
|__________|
| Keyboard |
|__________|
Now, when the last element of the ListView
is visible, the above happens. But when only middle elements are visible, this happens:
Before soft input:
__________
| 3 |
| 4 |
| 5 | <- ListView
| 6 |
|____7_____|
|__________| <- EditText
After soft input:
__________
| 3 |
| 4 |
|____5_____|
|__________|
| Keyboard |
|__________|
I have set windowSoftInputMode=adjustResize
for this activity in my manifest. Please advice me on how I can get the items to scroll up.