1

I have this code:

<RelativeLayout
          android:orientation="vertical"
          android:layout_height="match_parent"
          android:layout_width="398px"
          android:layout_marginTop="35px"
          android:layout_alignParentRight="true"  >
          ....
<ImageView
              android:layout_width="373px"
              android:layout_height="222px"
              android:layout_marginTop="35px"
              android:src="@drawable/hairfall_text"
              android:layout_below="@+id/pr_title" />
</RelativeLayout>

It renders this image to display like this on my device (P7500 Galaxy Tab 10.1 to be precise):

enter image description here

This is the actual drawable as it is in my resources folder:

enter image description here

Having already googled and exhausted relevant info, I already adjusted the image's pixel format to ARGB_8888 (32bit), also setting the activity's window pixelformat (getWindow().setFormat(PixelFormat.RGBA_8888);) does nothing.

I hope somebody can shed some light regarding this matter. Thanks alot.

lock
  • 6,404
  • 18
  • 58
  • 76
  • update: the solution i used was to add a no-dpi folder in the resources, android does not scale or resize any resource placed there although keep in mind that this is highly to produce a not enough memory error – lock Apr 23 '12 at 01:22

2 Answers2

1
  1. First of all if you can do than do "Wrap_content" for both height and width e.g. layout_height="wrap_content" and layout_width="wrap_content" for your ImageView.And also you can do same but fill_parent for your Parent RelativeLayout.
  2. Secondly use "dp" in place of "px".It is recommended.

LINK for android measurement. Try this if it will works.

Community
  • 1
  • 1
Android Killer
  • 18,174
  • 13
  • 67
  • 90
  • im completely aware of the rule not to use px although im breaking it in this case as per client's request, btw, the image uploaded here is not the actual image (it was clipped to hide corporate info) and i've just noticed that i've clipped the screenshot's image wrong too. but you get the idea, android render's it to display like that even when the imageview is explicitly told to render it in a 373*222 px box. – lock Mar 02 '12 at 06:17
  • oh wait, wrap_content did the job, the image is not garbled anymore, but it seems too small though so thanks. however, i'd like to know how android interprets that layout_height="222px" or layout_width="373px" ? does it convert it to DP? – lock Mar 02 '12 at 06:22
  • @lock Cheers !!! for your problem solution.I edited my answer with a link.Please check it hope it will help you.. – Android Killer Mar 02 '12 at 06:25
0

not fixed the height and width with values

 <RelativeLayout
      android:orientation="vertical"
      android:layout_height="fill_parent"
      android:layout_width="fill_parent"
      android:layout_marginTop="35dp"
      android:layout_alignParentRight="true"  >
      ....
<ImageView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_marginTop="35px"
          android:src="@drawable/hairfall_text"
          android:layout_below="@+id/pr_title" />
</RelativeLayout>
NagarjunaReddy
  • 8,621
  • 10
  • 63
  • 98