1

I'm trying to align an image to it's parents bottom. The basic idea is to fit the image to screen width, use wrap_content for height and then align all that to the parent's bottom. Unfortunately the result is a 1-2dp margin at the bottom I cannot get rid of. I changed the parent's background here to blue so it is obvious:

<RelativeLayout
    android:layout_gravity="center_horizontal"
    android:id="@+id/contentView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

   <ImageView
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_alignParentBottom="true"
       android:adjustViewBounds="true"
       android:scaleType="centerCrop"
       android:src="@drawable/top_graphic" />
//...
</RelativeLayout>

This is how it looks like in layout builder:

enter image description here

That blue line at the bottom I cannot get rid of. I don't want to use direct dp values obviously, how can I solve this?

Onik
  • 19,396
  • 14
  • 68
  • 91
breakline
  • 5,776
  • 8
  • 45
  • 84

1 Answers1

0

Try this

<ImageView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_alignParentBottom="true"
      android:adjustViewBounds="true"
      android:scaleType="fitXY"
      android:src="@drawable/top_graphic" />
Ratilal Chopda
  • 4,162
  • 4
  • 18
  • 31