2013-04-23 4 views
2

Когда я нажимаю в моем редактирования текста и моя клавиатура появляется, кажется, что все будет хорошо, как на картинке ниже:Макет изменения размера неправильно, когда клавиатура отображается

enter image description here

Но когда он должен сжать немного больше моего размер изображения, расширяя невидимую область, и мой TextView еще столь же большим, как и в начале, тогда мой макет больше не работает:

enter image description here

Я пытался создать новый образ s и размеры для разрешения xhdpi, но это не повлияло

Как это исправить? Как изменить размер пропорциональности. (Я пытался поставить Scrollview, но у меня есть ListView внутри моего макета, как вы можете видеть в коде ниже)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/login_background" 
    android:descendantFocusability="beforeDescendants" 
    android:clickable="true" 
    android:focusableInTouchMode="true" 
    tools:context=".LoginActivity" 
    android:id="@+id/fundoLogin" > 

    <RelativeLayout 
     android:id="@+id/relativeLayout2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" > 

     <ImageView 
      android:id="@+id/image_login_fields" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/image_logo" 
      android:layout_centerHorizontal="true" 
      android:contentDescription="@string/img_login_fields_desc" 
      android:src="@drawable/login_fields"> 

     </ImageView> 

     <ImageView 
      android:id="@+id/image_logo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:layout_marginBottom="@dimen/margin_logo_to_fields" 
      android:contentDescription="@string/img_logo_desc" 
      android:src="@drawable/logo" /> 

      <TextView 
       android:id="@+id/labelLogin" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignTop="@id/image_login_fields" 
       android:layout_alignLeft="@id/image_login_fields" 
       android:layout_marginTop="@dimen/margin_top_label_login" 
       android:layout_marginLeft="@dimen/margin_left_label_login" 
       android:text="@string/login" 
       android:textSize="@dimen/login_txt_size" 
       /> 

      <EditText 
       android:id="@+id/txtFieldLogin" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="@dimen/margin_left_txt_field_login" 
       android:layout_alignTop="@id/image_login_fields" 
       android:layout_toRightOf="@id/labelLogin" 
       android:layout_alignRight="@id/image_login_fields" 
       android:layout_marginRight="@dimen/margin_right_txt_field_login" 
       android:layout_marginTop="@dimen/margin_top_txt_field_login" 
       android:ems="10" 
       android:textSize="@dimen/login_txt_size" 
       android:hint="@string/txtFieldLoginHint" 
       android:singleLine="true" > 
      </EditText> 

      <TextView 
       android:id="@+id/labelSenha" 
       android:layout_below="@id/labelLogin" 
       android:layout_alignLeft="@id/image_login_fields" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="@dimen/margin_top_label_senha" 
       android:layout_marginLeft="@dimen/margin_left_label_senha" 
       android:text="@string/senha" 
       android:textSize="@dimen/senha_txt_size" /> 

      <EditText 
       android:id="@+id/txtFieldSenha" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/txtFieldLogin" 
       android:layout_alignLeft="@id/txtFieldLogin" 
       android:layout_alignRight="@id/txtFieldLogin" 
       android:layout_marginTop="@dimen/margin_top_txt_field_senha" 
       android:ems="10" 
       android:hint="@string/txtFieldSenhaHint" 
       android:singleLine="true" 
       android:textSize="@dimen/senha_txt_size"></EditText> 

      <ImageButton 
       android:id="@+id/btnEntrar" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignRight="@id/image_login_fields" 
       android:layout_alignBottom="@id/image_login_fields" 
       android:layout_marginRight="@dimen/margin_right_btn_entrar" 
       android:layout_marginBottom="@dimen/margin_bottom_btn_entrar" 
       android:background="@drawable/btn_entrar_clicked" 
       android:contentDescription="@string/btn_entrar_desc" 
       /> 

     <ListView 
      android:id="@+id/listEmails" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@id/image_login_fields" 
      android:layout_alignRight="@id/image_login_fields" 
      android:layout_alignLeft="@id/txtFieldLogin" 
      android:background="@drawable/rounded_corner" 
      android:visibility="invisible" > 
     </ListView> 

    </RelativeLayout> 

    <Button 
     android:id="@+id/btnTeste" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:textSize="@dimen/btn_teste_txt_size" 
     android:layout_marginRight="@dimen/margin_right_btn_teste" 
     android:layout_marginBottom="@dimen/margin_bottom_btn_teste" 
     android:text="@string/btnCredenciaisDeTesteTxt" 
     android:textColor="@color/white" /> 

</RelativeLayout> 

ответ

3

Что вы ищете атрибут android:windowSoftInputMode в AndroidManifest. Это определяет, как ваш экран будет реагировать на отображаемую клавиатуру. Сейчас кажется, что он использует adjustResize и вы хотите adjustPan так в вашем Activity декларации в манифесте добавить:

<activity android:windowSoftInputMode="adjustPan" 

Вы можете прочитать больше о ваших вариантов здесь:

http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

Если у вас хотите изменить размер экрана, вам нужно переосмыслить свой макет.

Во-первых, его плохая форма, чтобы иметь фон входа в систему как отдельный ImageView. Поскольку вы хотите изменить размер, вы должны создать 9 патчей для изображения с наименьшим необходимым размером. Это позволяет контейнеру определить размер изображения, а не самого изображения.

Во-вторых, оберните TextViews и EditText в RelativeLayout покое затем применить 9 патч, созданный в качестве фона в RelativeLayout. Теперь у вас всегда будет окно для входа, которое обертывает ваши представления так, как вы его проектировали, даже когда они изменяются.

+0

Acutually adjustPan - это то, что я сделал сейчас, но это не совсем то, что я хочу. –

+0

обновил мой ответ – JustinMorris

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