I have a very simple RelativeLayout :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frag"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ListView
        android:id="@+id/listApplications"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

    <!-- AD SERVER -->

    <ImageView
        android:id="@+id/ad_server_picture"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="0dp"
        android:contentDescription="@string/ad_banner_image_description"
        android:gravity="bottom|center_horizontal"
        android:paddingBottom="0dp" />

</RelativeLayout>

ImageView is aligned to the bottom of its parent (RelativeLayout) and I set padding/ margin to 0, but I get a white "border" on the top and bottom of the image (see the red mark):

enter image description here

Thank you !

有帮助吗?

解决方案

Use android:scaleType="fitXY" to keep the image fit the screen. change your ImageView to this.

 <ImageView
        android:id="@+id/ad_server_picture"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:scaleType="fitXY"      
        android:contentDescription="@string/ad_banner_image_description"
        android:gravity="bottom|center_horizontal"
        />

HIH.

其他提示

In ImageView you can add this android:adjustViewBounds="true" will work fine!

add attibute android:layout_aboveto the listview, with value @+id/ad_server_picture

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top