0

I want to use an image as a Button for an Android App, so I'm using an ImageButton. I want it to be pretty big so I understood the best way to do it is to configure the background of the image as the image I want. I'm setting the layout width and height to 250dip but I'm getting a pretty low resolution. The image is of 1000X1000 px so there is no real reason it would show pixelated as it is showing... Is there any way to resolve this? To set the image button to be pretty big and using a better quality image (from the drawable-xhdpi for example)? Thanks!

EDIT:

This is the code for the imageView:

<ImageView
    android:id="@+id/activateButtonImage"
    android:layout_width="250dip"
    android:layout_height="250dip"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:contentDescription="@null"
    android:minHeight="250dip"
    android:minWidth="250dip"
    android:scaleType="centerInside"
    android:background="@drawable/deactivateicon"
    />

ScreenShot: Screenshot showing image in low quality

Javi
  • 889
  • 1
  • 16
  • 41
  • Both answeres where correct, my problem was importing the pictures to the project usibg eclipse. It was scaling them weird and using a low def property. The solution was just copying the insge into the project folders. Thanks! – Javi Mar 10 '14 at 08:48

2 Answers2

1

Your image is plenty big. Try adding:

android:scaleType="centerInside" to your ImageButton in the xml layout file.

Gabe
  • 1,239
  • 1
  • 13
  • 20
1

You can also use an ImageView with onClick to act as a button. If the image is a resource, reference it in the android:src=@drawable/image parameter and scale it as suggested by Gabe's answer.

ono
  • 2,984
  • 9
  • 43
  • 85
  • I'm trying with what you said and including @Gabe's answer but the symbol now seems very small.. (It's not getting bigger) This is what I wrote: – Javi Dec 26 '13 at 11:19
  • it shouldnt be small if the image is 1000x1000 and your view is 250dp by 250 dp. Can you post screen shot? – ono Dec 26 '13 at 22:59
  • im not sure why your image is appearing scaled up if it is the size you mentioned. play around with the scaleType, padding, or the view width and height. make sure you're referencing the drawable with `android:src` instead of `android:background` – ono Dec 30 '13 at 01:03