Reputation: 186
Hi I'm designing a navigation application for as a Uni project. I'm having problems with getting the button to stay underneath the soft keyboard when it appears. I'm using LinearLayout as a frame. I've searched a lot and tried different techniques but nothing seems to work.
Here is my XML file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="0px"
android:layout_height="0px"
android:focusable="true"
android:focusableInTouchMode="true" />
<requestFocus />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:orientation="vertical" >
<EditText
android:id="@+id/navi_searchfield1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Current location" >
</EditText>
<ListView
android:id="@+id/navi_listview1"
android:layout_width="fill_parent"
android:layout_height="0dp">
</ListView>
<EditText
android:id="@+id/navi_searchfield2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Destination" />
<ListView
android:id="@+id/navi_listview2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
<Button
android:id="@+id/start_navigation"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:background="@drawable/start"
android:textColor="#ffffff"
android:text="Start navigation" />
</LinearLayout>
Upvotes: 0
Views: 1614
Reputation: 11889
Add android:windowSoftInputMode="adjustPan"
to your activity in AndroidManifest.xml as:
<activity
android:windowSoftInputMode="adjustPan"
.
.
.
</activity>
This will prevent SoftKeyboard from moving your button, giving you an output like:
You can use the button even though the keyboard is shown by scrolling on the screen. But I think you probably can't show the keyboard above the button because I worked with SoftKeyboard and it uses:
android:layout_alignParentBottom="true"
So, you can only keep your layout safe from being pushed by SoftKeyboard.
Upvotes: 1