Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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:
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?
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.
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.
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.
Thanks for contributing an answer to Stack Overflow!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.