Scale Drawable - does setImageLevel dictate the scale?
Asked Answered
T

1

8

I have created a small test app to try out scale drawable.

I define my drawable in xml and save it as scale_up.xml. I have a main.xml layout file with an ImageView. I use android:src="@drawable/scale_up" in the ImageView to use the drawable I created in xml. In my activity I use myImageView.setImageLevel(some level here) to set the level of the ImageView defined in main.xml. All's well and the ImageView displays the drawable defined in scale_up.

My confusion is the following:

  • changing the scaleHeight and scaleWidth % in scale_up.xml makes no perceivable difference if the level is set at 10000
  • changing the level in setImageLevel (between 0 and 10000) changes the size of the image - really only perceivable at around 5000. the higher the % value for scaleHeight and scaleWidth, the smaller the image (depending on the value of setImageLevel())

I suppose my question/s are:

  1. is it correct to use setImageLevel(), passing a level between 0 and 10000 - in the activity to control the size of the drawable defined in the xml file?
  2. what is the relationship between scaleHeight, scaleWidth and setImageLevel() - as I see it now, I may as well just set the scaleHeight and scaleWidth to 100% and then use setImageLevel(5000) to get a 50% scaled image - i.e increasing or reducing setImageLevel(0 to 10000) will change the scale - making the scaleHeight and scaleWidth % pretty pointless.

appreciate any clarification of this and perhaps an example of how to use scale drawable (defined in xml) correctly.

Thurmond answered 26/3, 2012 at 14:30 Comment(0)
C
-1
  1. No. setImageLevel is more like an enumerated type for images. It's for displaying different images for say, a battery charged level, or a signal bars display. You put one image under level 1 for low battery, another under 2 for medium battery, and so on. Then you use setImageLevel to switch between them. At least that's been my understanding. That said, I have no idea why it changes the scale.

  2. I have no idea why any of that would be. It could be an issue with the xml editor/viewer in the ADT in eclipse, I've noticed many things display well on my phone, yet incredibly badly on my editor. I generally just work in xml for that reason.

What are you trying to accomplish exactly? That might make it easier to answer your question.

Cubage answered 12/2, 2013 at 16:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.