7

listView 内に imageView があります。次のように設定します: main.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="wrap_content"
    android:orientation="vertical" >

  <ListView
    android:id="@+id/listView2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >
  </ListView>

</LinearLayout>

image.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="vertical" >

  <ImageView
    android:id="@+id/imageView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"    
    android:scaleType="center"    
    android:src="@drawable/ic_launcher" />

</RelativeLayout>

これはうまく機能し、URL から多くの画像を http リクエストで埋めます。しかし、画像のサイズに問題があります。解像度やサイズに関係なく、画面いっぱいに表示したい。さまざまなレイアウトの高さ、幅、およびスケールタイプで試しましたが、正しく機能しません。

1枚目は今の状態、2枚目は自分のなりたいイメージです。

編集: scaleType="fitXY" で試してみると、幅が 100% になりましたが、長い画像では高さが悪くなります。

これが今の姿です これは私がそれをどのように見せたいかです

4

7 に答える 7

1

NinePatch イメージを使用する

リンクはこちら

于 2013-09-18T11:28:02.730 に答える
0

使用の代わりに、またファイルの使用でもandroid:src="@drawable/ic_launcher"android:background="@drawable/ic_launcher"java

yourImageView.setBackgroundDrawable(new BitmapDrawable(getResources(), bitmap));

これを使用android:srcすると、解像度に応じて画像が画面に収まるように設定されます。画像を背景として設定すると、必要に応じwidthて設定できますheight

于 2013-09-13T10:01:03.013 に答える
0

画像ビューでandroid:adjustViewBounds="true"およびandroid:scaleType="centerInside"を使用したいようです。

また、image.xml の RelativeLayout を使用して、質問に示されていない何か他のことをしていない限り、それは無意味です。

于 2013-09-13T10:28:52.507 に答える