24

私は Android に 2 つの画像を縦に並べた単純な LinearLayout を持っています。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.eataly.android" 
    android:orientation="vertical"
    android:background="@android:color/white"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/img_header1"
        />

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/img_header2"
        />
</LinearLayout>

次のリンクでわかるように、画像の上部と下部のギャップを取り除くことができません: http://img185.imageshack.us/img185/8484/senzanomev.png

LinearLayout と ImageViews で考えられるすべてのことを試しました。

android:padding="0px"
android:top="0px"
android:bottom="0px"
android:top="0px"
android:layout_margin="0px"

成功しませんでした。これらの空の境界線を削除するにはどうすればよいですか?

4

3 に答える 3

69

私は解決策を見つけました。ImageViewこの属性を:に追加する必要がありました。

android:adjustViewBounds="true"
于 2010-10-10T09:11:02.270 に答える
4

xml レイアウトに android:scaleType="fitXY" を追加します。

于 2014-04-15T07:03:20.687 に答える
0


上部の ImageViewの線形レイアウトでこれを行うには:android:gravity="bottom"
下部の ImageView の場合:android:gravity="top"
本当に RelativeLayout を使用したくないですか? 2 つの画像を互いに位置合わせしようとしている場合は、それが道を進む方法のようです。

于 2010-09-01T02:19:21.487 に答える