1

imageviewとlistviewを2つの別々の相対レイアウトに配置しようとしていますが、imageviewに画像を追加すると、画像の高さが本来より低くなり、画像とlistviewの間に黒いスペースが追加されます。しかし、textviewを配置すると、正常に機能します。これがコードスニペットです。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout android:id="@+id/header"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight">
<ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginTop="-10dp"
        android:src="@drawable/bar" />

</RelativeLayout>

<ListView
android:id="@+id/list11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="65dp"
android:cacheColorHint="#000000"
android:focusable="false"
android:listSelector="@color/itemcolor1"
android:scrollbars="vertical"
android:scrollingCache="false" >
</ListView>

</RelativeLayout>

みんなありがとう、それは迷惑です

4

4 に答える 4

1

答えてくれてありがとう、それを修正するのをたくさん助けました、しかしこれらの答えは微調整が必​​要なので、私は他の人のために将来の参考のためにここに書いています

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
  android:layout_height="match_parent" >
  <ImageView
    android:id="@+id/imageView1"
    android:layout_width="match_parent"
    android:layout_height="65dp"
    android:layout_alignParentTop="true"
    android:layout_alignParentRight="true"
    android:scaleType="fitXY"
   android:layout_weight="2"
    android:layout_marginTop="-10dp"
    android:src="@drawable/bar" />

  <ListView
   android:id="@+id/list11"
   android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/imageView1"
    android:cacheColorHint="#000000"
    android:focusable="false"
    android:layout_weight="8"
    android:scrollbars="vertical"
    android:scrollingCache="false"
    android:listSelector="@color/itemcolor1">
    </ListView>

  </RelativeLayout>
于 2013-02-06T05:04:01.450 に答える
0

画像ビューのスケールタイプを設定してみてください。

android:scaleType="fitXY"
于 2013-02-05T11:39:27.710 に答える
0

これを試してください:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginTop="-10dp"
        android:scaleType="center"
        android:src="@drawable/bar" />

<ListView
android:id="@+id/list11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView1"
android:layout_marginTop="65dp"
android:cacheColorHint="#000000"
android:focusable="false"
android:listSelector="@color/itemcolor1"
android:scrollbars="vertical"
android:scrollingCache="false" >
</ListView>

</RelativeLayout>
于 2013-02-05T11:45:23.160 に答える
0

これを試して...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="10"
android:orientation="vertical"
 >
<ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="0dip"
       android:layout_marginTop="-10dp"
        android:scaleType="fitXY"
        android:layout_weight="2"
        android:src="@drawable/actionbar_background"
        android:adjustViewBounds="true"
        />

<ListView
android:id="@+id/list11"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView1"
android:cacheColorHint="#000000"
android:focusable="false"
android:layout_weight="8"
android:scrollbars="vertical"
android:scrollingCache="false" >
</ListView>

</LinearLayout>
于 2013-02-05T12:05:11.550 に答える