0

タイトルが言ったように、画像の前後に「スペース」があり、私はそれを望んでいません。

<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/fond"
    >


    <ImageView
        android:id="@+id/imageView1"
        android:contentDescription="@string/desc"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/top" 
        android:layout_gravity="top"        
    />

    <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/fond1"
        >



    </LinearLayout>    
</LinearLayout>

ご覧のとおり、背景付きの最初のレイアウトがあります。ImageView は直後にあり、一番上にあるはずですが、そうではありませんでした。2 番目のレイアウトは、画像よりも後になっています。->

最初のレイアウト

--不要なスペース--

画像

--不要なスペース--

2 番目のレイアウト

この「スペース」を削除する方法を知っている人がいたら、ありがとう。

4

2 に答える 2

2

内で使用android:adjustViewBounds="true"しますImageView。そうImageViewすれば、提供された画像の境界に合わせて調整されます。

于 2012-07-27T13:10:46.107 に答える
0

この方法で相対レイアウトを使用します::

<RelativeLayout 
   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/fond"
   >


<ImageView
    android:id="@+id/imageView1"
    android:contentDescription="@string/desc"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/top" 
    android:layout_gravity="top"  
    android:layout_alignParentTop="true"
/>

<LinearLayout 
    android:layout_below="@+id/imageView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@drawable/fond1"
    >
</LinearLayout>    
</RelativeLayout>
于 2012-07-27T12:54:32.217 に答える