Android 将布局移到软键盘上方
我试着用谷歌搜索我的问题,但找不到任何可以帮助我的东西,或者我就是不明白。 当软键盘打开时,我想在上面移动一些控件,这是可能的。具体地说,我想把所有东西都移到login_btnLogin上面,包括软键盘弹出时的这个按钮Android 将布局移到软键盘上方,android,android-layout,android-softkeyboard,Android,Android Layout,Android Softkeyboard,我试着用谷歌搜索我的问题,但找不到任何可以帮助我的东西,或者我就是不明白。 当软键盘打开时,我想在上面移动一些控件,这是可能的。具体地说,我想把所有东西都移到login_btnLogin上面,包括软键盘弹出时的这个按钮 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_wi
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:padding="10dp" >
<ImageView
android:id="@+id/login_img_logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="40dp"
android:layout_marginTop="30dp"
android:contentDescription="@string/app_name"
android:scaleType="center"
android:src="@drawable/logo" >
</ImageView>
<RelativeLayout
android:id="@+id/login_loginLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_img_logo"
android:background="@drawable/rounded_edittext_with_gray_borderline"
android:paddingBottom="5dp" >
<EditText
android:id="@+id/login_txt_username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/rounded_edittext_without_borderline"
android:ems="10"
android:gravity="center_vertical"
android:hint="@string/register_username"
android:inputType="text"
android:textColor="@android:color/black" >
</EditText>
<View
android:id="@+id/login_separator"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_below="@+id/login_txt_username"
android:background="@android:color/darker_gray" />
<EditText
android:id="@+id/login_txt_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/login_txt_username"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignRight="@+id/login_txt_username"
android:layout_below="@+id/login_separator"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@drawable/rounded_edittext_without_borderline"
android:gravity="center_vertical"
android:hint="@string/register_password"
android:inputType="textPassword"
android:textColor="@android:color/black" >
</EditText>
</RelativeLayout>
<LinearLayout
android:id="@+id/login_buttonslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_loginLayout"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal" >
<Button
android:id="@+id/login_btnLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/button"
android:gravity="center"
android:text="@string/login"
android:textColor="#000000"
android:textSize="20sp"
android:textStyle="bold"
/>
</LinearLayout>
<RelativeLayout
android:id="@+id/login_bottom_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_buttonslayout"
android:layout_marginBottom="10dp"
android:orientation="vertical" >
<TextView
android:id="@+id/login_txt_forgot_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:gravity="center_horizontal"
android:text="@string/forgotPassword"
android:textColor="@android:color/background_dark"
android:textSize="15sp"
android:textStyle="bold" >
</TextView>
<Button
android:id="@+id/login_btn_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@string/forgotPassword"
android:background="@drawable/info"
android:textAppearance="?android:attr/textAppearanceSmallInverse"
android:textColor="@android:color/primary_text_light" />
</RelativeLayout>
</RelativeLayout>
使用此
在Manifest.xml中:
android:configChanges="keyboardHidden|orientation"
及
请让我知道使用这两种方法是否对您有帮助,并在虚拟键盘出现问题的布局中使用scrollview。这也有点帮助。请尝试使用此方法:这将适用于所有设备
android:configChanges="orientation|screenSize|keyboardHidden"
您仍然会遇到问题,然后尝试将其添加到清单文件中
android:windowSoftInputMode="stateAlwaysHidden"
试着集中编辑文本,以便在第一时间解决布局问题。我已经尝试了软输入模式,但id没有帮助。在滚动视图中,我还将所有内容都放在了登录底部布局之上,但它会移动登录底部布局,其余视图保持原样。我的应用程序屏幕方向始终是纵向的,屏幕大小无法识别,键盘隐藏,在这一更改上我该怎么办?我试着把重点放在edittext上,但它只是移动了edittext,而不是整个布局。你能找到解决问题的方法吗?
android:windowSoftInputMode="stateAlwaysHidden"