2012-03-14 63 views
0

我在ListView上方获得了静态ImageView。 但imageView显示上面有一些空的空间。ImageView上方的空白位置

我怎样才能删除这个空的空间?

- 当我使用的图像作为一个TextView的背景及其在母公司顶

这里是我的ImageView的XML完美神韵::

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

<ImageView 
     android:id="@+id/titlebartear" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_marginTop="-5dip" 
     android:src="@drawable/titlebartear" 
     /> 

<ListView android:id="@android:id/list" 
    android:paddingTop="0px" 
    android:tag="fileslist" 
    android:fastScrollEnabled="true" 
    android:smoothScrollbar="true" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:divider="@color/pijndagboek_light_blue" 
    android:dividerHeight="2px" 
    android:cacheColorHint="#00000000" 
    android:layout_below="@id/titlebartear" 
    /> 

</RelativeLayout> 
+0

您是否尝试过使用android:scaleType参数? http://developer.android.com/reference/android/widget/ImageView.html#attr_android:scaleType; http://developer.android.com/reference/android/widget/ImageView.ScaleType.html – jcxavier 2012-03-14 12:13:36

+0

你可以发布这个意图的所有.xml文件吗? (通常是它的main.xml,但你可能已经改变了。)这个问题可能在文件的其他地方。 – pogo2065 2012-03-14 12:15:35

+0

这是所有的布局@JamesWright – Luciano 2012-03-14 12:34:01

回答

0

设置你的图片作为背景,以您的ImageView的。

<ImageView 
     android:id="@+id/titlebartear" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:background="@drawable/titlebartear" 
     /> 
+0

这种不利于使用ImageView的目的,虽然。 – jcxavier 2012-03-14 12:12:40

+0

空间来了,因为你的原始图像可能有这个空间 – 2012-03-14 12:14:40

+0

当我用它作为背景时,我的图像显示正确。但我已经找到了一个解决方案,通过设置-5dip的marginTop(仍然奇怪) – Luciano 2012-03-14 12:15:00

0

机器人:layout_marginTop = “ - 5dip”

工作:S

3

有点晚,但可以帮助其他人碰到这个stubmle:

“调整ViewBounds”工作对于我来说,当一个drawable自动缩放它所设置的View的高度。 (导致图像本身之上和之下的空白空间)