2013-02-21 2 views
1

Я попытался решить мою проблему, но не смог найти ничего, что могло бы мне помочь, или я просто не понял. Я хочу переместить некоторые элементы управления над мягкой клавиатурой при ее открытии, возможно ли это. Чтобы быть конкретным, я хочу переместить все выше login_btnLogin, включая эту кнопку, когда появляется мягкая клавиатура.Переместить макет над мягкой клавиатурой

<?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> 
+0

Вы нашли решение проблемы? – Hamid

ответ

0

использование этого

В Manifest.xml:

android:configChanges="keyboardHidden|orientation" 

и

android:windowSoftInputMode="adjustPan" 

Позвольте мне знать, используя как это полезны для вас или нет, а также использовать Scrollview в макет, где ваша виртуальная клавиатура создает проблему, также помогает немного

+0

Я уже пробовал режим мягкого ввода, но идентификатор не помог. Я также поставил все выше login_bottom_layout в режиме прокрутки, но он перемещает login_bottom_layout, и остальная часть просмотров остается такой, какая есть. – Damir

0

Попробуйте использовать это: Это будет работать на всех устройствах.

android:configChanges="orientation|screenSize|keyboardHidden" 

И вы все равно получите проблемы, то попробуйте добавить это в вашем файле манифеста

android:windowSoftInputMode="stateAlwaysHidden" 

Попробуйте сосредоточить свое EditText так, чтобы в кулак времени, так что ваша проблема макет может быть решительность.

+0

Моя ориентация экрана приложения - это всегда портрет, screenSize не распознается, клавиатураHidden - что мне делать с этим изменением? Я попытался сосредоточиться на edittext, но он просто перемещает, что edittext и не весь макет – Damir

+0

неправильно, он не работает! –

Смежные вопросы