vivek_Android
vivek_Android

Reputation: 1697

android image view problem

I have one question. I want to set one image to image button. I have one button image of size 90 x 48. I want to set this image on Image button.

Problems:

  1. I need to set image on background parameter or src parameter?
  2. If i set image on background parameter its not showing its actual size(smaller than actual size) if i have set the Layout width = wrap content and Layout Height= wrap content. If i give Layout width = 98dip and Layout Height= 48dip then its showing the same size. Is it a coorect way?

thanks

Upvotes: 0

Views: 829

Answers (2)

Dharmendra
Dharmendra

Reputation: 34016

  1. set image as background Parameter sometimes src makes problem
  2. if you are set width and height as wrap_content then android will check the screen size and try to adjust to your screen if screen size is big then android displays your image as its actual height and width and if screen size is less then it will compress your image

so best way is to set height and width is as wrap_content if you have to use portrait and landscape mode both

Upvotes: 1

Divers
Divers

Reputation: 9569

  1. Yes.
  2. If you use Layout width = wrap content and Layout Height= wrap content, image will be as actual size. Maybe just the density of your monitor is less than the density of your phone? Remember dip != pixels.

Upvotes: 1

Related Questions