问题
I got a static ImageView above a listView. But the imageView is showing some empty space above it.
How can i remove this empty space?
-when i use the the image as background of a TextView its perfectly alligned at parent top
Here is my xml for the ImageView:
<?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>
回答1:
A bit late, but may help others that stubmle across this:
"Adjust ViewBounds" worked for me, when a drawable automatically scales the height of the View it's set to. (Resulting in empty space above and below the image itself)
回答2:
set your image as background to your Imageview.
<ImageView
android:id="@+id/titlebartear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@drawable/titlebartear"
/>
回答3:
android:layout_marginTop="-5dip"
worked :S
来源:https://stackoverflow.com/questions/9701685/empty-space-above-imageview