title: Android listview item display text over image using array adapter
body: <p>I have overloaded the getView method of listview to populate custom style of list item. </p>
  
  <p>This is what currently it looks like:!!</p>
  
  <p><img src="https://i.stack.imgur.com/zyzu7.png" alt="enter image description here"></p>
  
  <p><em>Red color is to just show the background of listview item</em></p>
  
  <p>Here I have used 3 controls: Imageview for image, 2 text views (one top, one bottom).</p>
  
  <p>Problem here is the height of listview item is getting increased. I want two textviews over the image not above or below. To someextent I know the root cause of this problem but don't know how to fix it.</p>
  
  <p>Here is the layout of listview item:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="horizontal" 
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:padding="5dp"   &gt;
  
    &lt;ImageView android:id="@+id/imgIcon"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginRight="5dp" 
      android:scaleType="fitCenter"/&gt;
  
     &lt;TextView android:id="@+id/txtTitle"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:gravity="top"
      android:textStyle="bold"
      android:textSize="20sp"
      android:textColor="#FFFFFF"
      android:layout_marginLeft="10dp"
      android:layout_marginTop="2dp"
      android:layout_alignLeft="@+id/imgIcon"
      android:layout_alignTop="@+id/imgIcon"
      android:layout_alignBottom="@+id/imgIcon"/&gt;
  
     &lt;TextView android:id="@+id/txtTime"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:gravity="bottom"
      android:textStyle="bold"
      android:textSize="18sp"
      android:textColor="#FFFFFF"
      android:layout_marginLeft="10dp"
      android:layout_marginBottom="5dp"
      android:layout_alignLeft="@+id/imgIcon"
      android:layout_alignTop="@+id/imgIcon"
      android:layout_alignBottom="@+id/imgIcon"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>The problem is i'm using png image for Imageview and their size is getting increased in some aspect ratio. In case I hard code the height of listview item layout then, specifically on my phone screen size, things start appearing good but on some different screen size things get totally worse (which makes sense too).</p>
  
  <p><img src="https://i.stack.imgur.com/9Dwed.png" alt="enter image description here"></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="horizontal" 
  android:layout_width="fill_parent"
  android:layout_height="70dp"
  android:padding="5dp"   &gt;
  </code></pre>
  
  <p>Would be great if someone can explain about how to do it. Main problem is to display text over an image (and image is not same). Thanks.</p>
  
  <p>Update: My major problem is I don't have the bit vector of image instead a PNG and it tries to scale up the image. (<em>setting scale type to center-fit could be an option but would it work on background resourcE?</em>. Here is the output if I set image as a background for listview item and two texts over it.
  <img src="https://i.stack.imgur.com/jiZys.png" alt="enter image description here"></p>