0

Я хочу, чтобы сохранить размер экрана в Layout, когда появляется клавиатура, моя идея получить следующий в обеих случаях (с клавиатурой или без него):Компоновки Изменения размера при появлении клавиатуры (Scrollview)

 
|-----------------| 
|  image  | 
|     | 
|-----------------| 
|     | 
| center lay | 
|     | 
|-----------------| 
|     | 
|  image  | 
|-----------------| 

Но в в макете центра у меня есть EditText, и когда появляется мягкий KeyBoard, макет центра уменьшает его высоту и короче, в результате чего первый EditText прилипает к изображению выше. Я попробовал несколько форм, например, с RelativeLayout выровнять изображения сверху и снизу, но когда клавиатура появляется, скрывает макет центра и вызывает ужасный эффект.

Это мой код теперь,

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fillViewport="true"> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <ImageView 
      android:id="@+id/login_iv_points_top" 
      android:layout_width="fill_parent" 
      android:layout_height="100dp" 
      android:layout_gravity="top" 
      android:src="@drawable/image" /> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:gravity="center_vertical" 
      android:orientation="vertical" > 

      <EditText 
       android:id="@+id/login_et_email" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="@dimen/login_edit_margin_left" 
       android:layout_marginRight="@dimen/login_edit_margin_right" 
       android:ems="10" 
       android:hint="@string/login_et_email" 
       android:inputType="textEmailAddress" /> 

      <EditText 
       android:id="@+id/login_et_pass" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="@dimen/login_edit_margin_left" 
       android:layout_marginRight="@dimen/login_edit_margin_right" 
       android:layout_marginTop="@dimen/login_edit_pass_margin_top" 
       android:ems="10" 
       android:hint="@string/login_et_pass" 
       android:inputType="textPassword" /> 

      <Button 
       android:id="@+id/login_bt_login" 
       android:layout_width="match_parent" 
       android:layout_height="@dimen/login_button_height" 
       android:layout_marginLeft="@dimen/login_button_margin_left" 
       android:layout_marginRight="@dimen/login_button_margin_right" 
       android:layout_marginTop="@dimen/login_button_margin_top" 
       android:background="@drawable/bt_selectable_degraded_style" 
       android:text="@string/login_bt_access" 
       android:textColor="@color/bt_text_color" /> 

      <TextView 
       android:id="@+id/login_tv_forgot_pass" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:layout_marginTop="@dimen/login_forgot_margin_top" 
       android:linksClickable="true" 
       android:onClick="registerForgotClick" 
       android:text="@string/login_tv_forgot_pass" 
       android:textColorLink="@color/company_color" /> 
     </LinearLayout> 

     <ImageView 
      android:id="@+id/login_iv_points_bottom" 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:layout_gravity="bottom" 
      android:src="@drawable/image" /> 
    </LinearLayout> 

</ScrollView> 
+0

Вы выяснили, как это сделать? У меня такая же проблема. – jplaza

ответ

2

Может быть, вы можете попробовать поставить android:windowSoftInputMode="adjustNothing" на узле деятельности вашего Android Manifest. Затем клавиатура появится поверх содержимого.

+1

Но с этой опцией у меня нет ScrollView. –

+0

Это сработало для меня. Благодаря! – kevinkl3

0

Попробуйте использовать это в деятельности внутри файла манифеста:

android:configChanges="keyboardHidden|orientation" 
android:windowSoftInputMode="adjustPan" 
+0

Получите тот же результат, который я комментирую @Esteam. –

0

Если вы удалите windowSoftInputMode из манифеста вы будете потерями вашей скроллинг, так что если у вас есть статическое изображение я имею в виду из растяжимого ресурса, чем попробовать этот GetWindow () .setBackgroundDrawableResource (R.drawable.ic_launcher);

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