0
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:scaleType="fitXY"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:padding="5dip">

    <ImageView android:id="@+id/header"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:src="@drawable/green_bg" />

</RelativeLayout>

This is my Header Layout, I need to stretch the image to something like this below. http://postimage.org/image/gfebtdxgj/

  1. How can I add the two buttons, left and right above the image.
  2. How to stretch the header image.
Cœur
  • 37,241
  • 25
  • 195
  • 267
theJava
  • 14,620
  • 45
  • 131
  • 172

2 Answers2

0

possible duplicate of:

android: stretch image in imageview to fit screen

Android docs http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

Community
  • 1
  • 1
Yngwie89
  • 1,217
  • 9
  • 17
0

use this code for both of your questions:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:scaleType="fitXY"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dip">
<Button
    android:id="@+id/btn1"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    />
<Button
    android:id="@+id/btn2"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    />
<ImageView android:id="@+id/header"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:src="@drawable/green_bg"
    android:scaleType="centerCrop"
    android:layout_below="@id/btn1"/>

 </RelativeLayout>
Matin Gdz
  • 217
  • 2
  • 13