0

ImageView が 1 つだけの GUI を作成しました。以下のコード:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/TableLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center|top"
    android:background="@drawable/exam_list_bg"
    android:gravity="top|center" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/exam_icon_failed" />

    </TableRow>

</TableLayout>

詳細情報: - Exam_icon_failed.png (97x175) - プレビュー デバイスとして Galaxy Nexus を使用しています (Eclipse で)

そして問題: - プレビュー画面では、画像が正常であることがわかります (比率を維持し、ストレッチはありません..) しかし、電話にインストールすると (プレビュー デバイスと同じ画面サイズ) -> 画像が引き伸ばされました。

この場合のアドバイスをいただけませんか?画像の比率を維持したい。どうもありがとう!

4

4 に答える 4

1

これを試してください:

<ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/exam_icon_failed"
            android:adjustViewBounds="true"/>

可能であれば、画像に 9 パッチを適用します。お役に立てれば。

于 2013-08-10T16:47:32.920 に答える
1

次のように、 scaleTypeを ImageViewに追加します。

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="centerInside"
        android:src="@drawable/exam_icon_failed" />
于 2013-08-10T16:19:35.707 に答える
1

画像ビューを次のように変更します

<ImageView
   android:id="@+id/imageView1"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:scaleType="center" 
   android:src="@drawable/exam_icon_failed" />

あなたと誰かを助けるかもしれません..

于 2013-08-10T18:43:16.560 に答える