我有一个与我的相对布局底部对齐的按钮,我希望在显示软键盘时将其向上推,但我不希望它与其他视图重叠,任何提示?
<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"
下面是图片:
答案 0 :(得分:2)
问题是您使用alignParentBottom=true
作为按钮。尝试构建布局而不将此参数设置为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" />
修改强>
正如文件所说:
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.
我建议你重新考虑设计,并使用adjustPan而不是adjustResize。
但是,如果您的下一个按钮用于浏览您的编辑文本而不是查看this
答案 1 :(得分:0)
尝试使用此android:windowSoftInputMode="stateUnchanged|adjustResize"