2

When I click in my edit text and my keyboard shows up, everything seems to be ok as in the picture bellow:

enter image description here

But when it has to shrink a little bit more my image is resized extending a invisible area, and my TextView still as big as in the begining, then my layout doesn't work anymore:

enter image description here

I've tried to create new images and dimensions for xhdpi resolution, but it didn't any effect

How can I fix it? How can I resize everything proportionaly. (I've tried to put a scrollview but i have a ListView inside my layout, as you can see in the code below)

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

1 回答 1

3

您正在寻找的android:windowSoftInputModeAndroidManifest. 这控制您的屏幕如何响应显示的键盘。现在它似乎正在使用adjustResize,并且您希望在清单adjustPan中的Activity声明中添加:

<activity android:windowSoftInputMode="adjustPan"

您可以在此处阅读有关您的选择的更多信息:

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

如果你想调整屏幕大小,你需要重新考虑你的布局。

首先,将登录背景作为单独的 ImageView 是一种糟糕的形式。由于您希望它调整大小,您应该以最小的必要大小为图像创建一个 9 补丁。这使得容器定义图像的大小,而不是图像本身。

其次,将你的TextViewsand单独包装起来EditTextRelativeLayout然后应用你创建的 9 补丁作为RelativeLayout. 现在,您将始终拥有一个登录框,它可以按照您设计的方式包装您的视图,即使在调整大小时也是如此。

于 2013-04-23T17:41:46.293 回答