imagebutton: src should fit height but not lenght

56 views Asked by At

I want my big picture to fit the whole screen, but also it should overlap at the width.

have tried this:

   <ImageButton
       android:id="@+id/gameover"

       android:layout_width="wrap_content"
       android:layout_height="match_parent"
       android:src="@drawable/farmlvl1"
        android:scaleType="matrix"
       android:visibility="visible" />

have a look at the picture:

enter image description here

3

There are 3 answers

2
Kevin van Mierlo On BEST ANSWER

Use this:

<ImageButton
     android:id="@+id/gameover"
     android:layout_width="wrap_content"
     android:layout_height="match_parent"
     android:src="@drawable/farmlvl1"
     android:scaleType="centerCrop"
     android:adjustViewBounds="true"
     android:visibility="visible" />

You also need adjustViewBounds because else it sometimes wouldn't fit the height.

0
Rakesh kumar On

   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:src="@drawable/farmlvl1"
    android:scaleType="matrix"
   android:visibility="visible" />
0
Suman Dey On
  1. Use RelativeLayout
  2. Check with this code:

      android:id="@+id/gameover"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:scaleType="matrix"
      android:src="@drawable/right_arrow"
      android:visibility="visible" />