0

私のアプリで Android OS がサイズ変更をどのように処理しているかに悩まされています。基本的に、480x800 (幅 480px) の背景画像と、幅 480px の下部にある画像があります。

以下に示すように、Galaxy S (480x800 画面) ではすべて問題なく表示されます。

ここに画像の説明を入力

ただし、Galaxy S3 (720x1280) では、以下に示すように、背景は幅 720 ピクセルに引き伸ばされますが、下部の画像は幅 640 ピクセルにしかなりません。

ここに画像の説明を入力

640x960 の画像を含む xhdpi フォルダーを作成しようとしましたが、同じことが起こります (背景が 720px に引き伸ばされ、画像のみが 640px に拡大されます)。「ScaleType」でも遊んでみましたが、今のところうまくいきません。

OSが2つの画像のサイズを異なるスケールで変更する理由と、それを修正する方法を知っている人はいますか?

XML は次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/bg" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/significados"
        android:layout_gravity="center"
        android:layout_marginTop="216dp"
        android:onClick="goToSignificados"
        />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/ranking"
        android:layout_gravity="center"
        android:onClick="goToRanking"
        />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/engracados"
        android:layout_gravity="center"
        android:onClick="goToEngracados"
        />

    <ImageView
        android:id="@+id/iv1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="60dp"
        android:clickable="true"
        android:contentDescription="@string/image"
        android:onClick="goToMarket"
        android:src="@drawable/googleplay" />

</LinearLayout>
4

1 に答える 1

1

より具体的な回答を得るには XML を投稿する必要がありますが、基本的にすべての「ビュー」は画像のスケーリングを異なる方法で処理する場合があります。

あなたの例では、

width = match-parent を使用して、ボタンを最後まで伸ばすことができます。

「背景」はデフォルトで引き伸ばされますが、並べて表示することもできます。「ボタン」には背景サイズの最小サイズがありますが、必要に応じて引き伸ばされます (ボタンのテキストが多すぎます)

補足として、画像の正確なピクセルに依存するべきではありません。9 パッチまたはタイル背景の作成を検討し、「マッチペアレント、重力など」などを利用するようにしてください。

于 2012-08-15T19:28:18.077 に答える