1

スタイルの画像背景のサイズを変更したいのですが、スタイルを使用して背景画像を表示する画像ビューがあります

スタイル:

 <style name="Background">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">50dp</item>
        <item name="android:orientation">horizontal</item>
        <item name="android:background">@drawable/img_background</item>
    </style>

だから私は "img_background" を持っていて、そのサイズは約 1920*1080 です。すべてのデバイスのサイズに合うように完璧にサイズを変更したいです。画面のサイズに応じて自動的にサイズを変更するにはどうすればよいですか?画像が適切に表示されず、画面に合わせて適切にサイズ変更されていません。

スタイルを持ち、その中に Image ビューを持つ LinearLayout があります。1920*1080 に適切に適合しません。たとえば、800*480 の解像度ではトリミングされ、きちんとサイズ変更されません。

<LinearLayout

            style="@style/Background"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" 
            >





            <ImageView

                android:contentDescription="@null"
                android:layout_marginBottom="8dip"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dip"
                android:layout_marginTop="8dip"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:clickable="false"
                android:paddingLeft="15dip"
                android:src="@drawable/img_background"
                />

        </LinearLayout>

ありがとう

4

2 に答える 2

0

xml の layout_width と layout_height を変更します

<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
于 2013-06-04T13:44:42.270 に答える
0

からスタイルを削除しますLinearLayout

これをあなたのimageViewとして入れてください:

<ImageView
  android:contentDescription="@null"
  android:layout_marginBottom="8dip"
  android:layout_marginLeft="8dp"
  android:layout_marginRight="8dip"
  android:layout_marginTop="8dip"
  android:layout_width="fill_parent"
  android:layout_height="50dp"
  android:clickable="false"
  android:paddingLeft="15dip"
  android:scaleType="centerInside"
  android:src="@drawable/img_background" />
于 2013-06-04T13:40:53.273 に答える