1

I have tried to google my problem but couldn't find anything that could help me, or I just did't understand. I want to move some controls above soft keyboard when it opens, is this possible. To be specific i want to move everything above login_btnLogin, including this button too when soft keyboard pops up.

<?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>
4

2 回答 2

0

用这个

在 Manifest.xml 中:

android:configChanges="keyboardHidden|orientation"

android:windowSoftInputMode="adjustPan"

让我知道使用这两种方法是否对您有帮助,并且在您的虚拟键盘产生问题的布局中使用滚动视图也有帮助

于 2013-02-21T13:12:57.960 回答
0

尝试使用这个:这将适用于所有设备。

android:configChanges="orientation|screenSize|keyboardHidden"

而且您仍然遇到问题,然后尝试将其添加到您的清单文件中

android:windowSoftInputMode="stateAlwaysHidden"

尝试集中您的 EditText 以便在第一时间解决您的布局问题。

于 2013-02-21T14:02:37.460 回答