[solved] imageview src size

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

[solved] imageview src size

Postby ricardo » Mon Jan 04, 2010 12:44 am

hey! I want to know if it's possible to know the size of the source of an imageview.
the problem is that I have an imageview with its width&height filling its parent, but the actual image is (and needs to be) smaller than the imageview. to do some calculations I need to get the size of the actual image (well, I could hard code it, but that wouldn't be so pretty...)

cheers!
Last edited by ricardo on Mon Jan 04, 2010 12:44 pm, edited 1 time in total.
ricardo
Freshman
Freshman
 
Posts: 2
Joined: Thu Dec 31, 2009 2:58 am

Top

Postby jwei512 » Mon Jan 04, 2010 10:16 am

It depends on how you're setting the image in your ImageView - if you're doing it by id (i.e. R.drawable.your_pic) then I don't know of any way to get the dimensions, but you can also set it by using a Bitmap which has a getHeight() and a getWidth() method associated with it.

So yea, if you want to dynamically set the width and height of the ImageView, I would try and get the image as a Bitmap first.

If this wasn't what you were looking, then try posting some of your code so we have a better idea of how exactly you want to do this.
- jwei

http://thinkandroid.wordpress.com
Examples, Code, and Tutorials
jwei512
Senior Developer
Senior Developer
 
Posts: 135
Joined: Mon Jul 27, 2009 9:35 pm
Location: Palo Alto, CA

Postby ricardo » Mon Jan 04, 2010 12:44 pm

that worked! thanks for the help
ricardo
Freshman
Freshman
 
Posts: 2
Joined: Thu Dec 31, 2009 2:58 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 5 guests