2

編集テキストをクリックしてキーボードが表示されると、次の図のようにすべて問題ないように見えます。

ここに画像の説明を入力

しかし、もう少し縮小する必要がある場合、画像のサイズが変更されて非表示領域が拡張され、TextView が最初と同じ大きさのままになると、レイアウトが機能しなくなります。

ここに画像の説明を入力

xhdpi解像度の新しい画像と寸法を作成しようとしましたが、効果はありませんでした

どうすれば修正できますか?すべてを比例してサイズ変更するにはどうすればよいですか。(スクロールビューを配置しようとしましたが、以下のコードでわかるように、レイアウト内に 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>
4

1 に答える 1

3

探しているのは、 のandroid:windowSoftInputMode属性ですAndroidManifest。これは、表示されているキーボードに画面がどのように反応するかを制御します。現在、使用しているように見えadjustResizeますが、マニフェストの宣言で次のように追加しますadjustPanActivity

<activity android:windowSoftInputMode="adjustPan"

オプションの詳細については、次を参照してください。

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

画面のサイズを変更したい場合は、レイアウトを再考する必要があります。

まず、ログインの背景を別の ImageView として持つのは不適切な形式です。サイズを変更したいので、必要な最小サイズで画像の 9 パッチを作成する必要があります。これにより、イメージ自体ではなく、コンテナがイメージのサイズを定義します。

TextViews次に、 andEditTextを単独でラップしRelativeLayout、作成した 9 パッチを の背景として適用しますRelativeLayout。これで、サイズが変更された場合でも、ビューを設計どおりにラップするログイン ボックスが常に表示されます。

于 2013-04-23T17:41:46.293 に答える