Reputation: 2535
I have a button aligned to the bottom of my Relative Layout which I want to be pushed up when soft keypad is shown, but I don't want it to overlap other views, any hints?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_app" >
<Spinner
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/Button01"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="02dp"
android:background="@drawable/options_bg" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignLeft="@+id/spinner1"
android:layout_below="@+id/textView6"
android:layout_marginTop="03dp"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageView1"
android:layout_below="@+id/spinner1"
android:layout_marginLeft="03dp"
android:layout_toRightOf="@+id/imageView1"
android:text="Date"
android:textColor="#002f44"
android:textSize="18sp" />
<Button
android:id="@+id/button2"
android:layout_width="170dp"
android:layout_height="30dp"
android:layout_alignLeft="@+id/textView1"
android:layout_alignRight="@+id/spinner1"
android:layout_below="@+id/textView1"
android:layout_marginTop="05dp"
android:background="@drawable/btn_calendar"
android:textColor="#FFBF00" />
<AutoCompleteTextView
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageView1"
android:layout_alignLeft="@+id/button2"
android:layout_alignRight="@+id/spinner1"
android:digits="abcdefghijklmnopwrstuvwxyzABCDEFGHIJKLMNOPWRSTUVWXYZ. "
android:ems="6"
android:hint="Enter Name"
android:inputType="textCapWords"
android:maxLength="25"
android:textColor="#002f44" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText1"
android:layout_below="@+id/editText1"
android:padding="03dp"
android:textColor="#610B0B" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:visibility="invisible" />
<Button
android:id="@+id/button1"
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@drawable/btn_addreminder"
android:text="Save"
android:textColor="#002f44"
android:textStyle="bold"
android:visibility="gone" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="-5dp"
android:background="@drawable/widget_style"
android:orientation="horizontal"
android:visibility="gone" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Self"
android:textColor="#002f44" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:text="Other"
android:textColor="#002f44" />
</RadioGroup>
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_alignRight="@+id/Button01"
android:text="Type "
android:textColor="#002f44"
android:textSize="18sp"
android:visibility="gone" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView4"
android:layout_below="@+id/radioGroup1"
android:layout_marginTop="25dp"
android:text="Name"
android:textColor="#002f44"
android:textSize="18sp"
android:visibility="gone" />
<AutoCompleteTextView
android:id="@+id/autoname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:digits="abcdefghijklmnopwrstuvwxyzABCDEFGHIJKLMNOPWRSTUVWXYZ. "
android:ellipsize="end"
android:ems="8"
android:hint="Friends Name"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#002f44"
android:visibility="gone" >
</AutoCompleteTextView>
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/spinner1"
android:layout_alignRight="@+id/spinner1"
android:layout_below="@+id/spinner1"
android:clickable="false"
android:lineSpacingExtra="2.3dp"
android:padding="10dp"
android:text="TextView"
android:textColor="#002f44"
android:textSize="14sp"
android:visibility="invisible" />
<Button
android:id="@+id/Button01"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:layout_marginTop="05dp"
android:background="@drawable/btn_exit"
android:textStyle="bold" />
<Spinner
android:id="@+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imageView1"
android:layout_alignRight="@+id/editText1"
android:layout_below="@+id/textView2"
android:layout_marginTop="03dp"
android:background="@drawable/drop_down" />
<Button
android:id="@+id/Button02"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="0dp"
android:layout_marginRight="20dp"
android:background="@drawable/btn_addreminder"
android:text="Next"
android:textColor="#002f44"
android:textStyle="bold" />
<Button
android:id="@+id/button4"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_alignBaseline="@+id/Button02"
android:layout_alignBottom="@+id/Button02"
android:layout_alignParentLeft="true"
android:layout_marginLeft="42dp"
android:background="@drawable/btn_addreminder"
android:text="Skip"
android:textColor="#002f44"
android:textStyle="bold" />
</RelativeLayout>
android:windowSoftInputMode="stateHidden|adjustResize"
below is the picture:
Upvotes: 0
Views: 1308
Reputation: 2582
The problem is that you use alignParentBottom=true
for your button. Try to construct the layout without setting this parameter to true.
<Button
android:id="@+id/Button02"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="0dp"
android:layout_marginRight="20dp"
android:background="@drawable/btn_addreminder"
android:text="Next"
android:textColor="#002f44"
android:textStyle="bold" />
EDIT
As the documentation says:
adjustResize The activity's main window is always resized to make room for the soft keyboard on screen.
adjustPan The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.
I suggest you to rethink the design, and use adjustPan instead of adjustResize.
But if your next button is meant to be used to navigate through your edit texts than take a look at this
Upvotes: 2
Reputation: 563
try to use this android:windowSoftInputMode="stateUnchanged|adjustResize"
Upvotes: 0