android - Getting bitmap size in pixels on screen, not the actual size? -
i have layout has horizontal scroll on top, text box on bottom , whatever space left in middle fill imageview. in imageview load bitmap. let's call imageview bottom one.
now, on top of imageview load dynamically imageview user can move dragging it. second imageview (top one) has small icon in overlayed on top of bitmap , saved. think of logo/watermark.
both imageviews in relativelayout, can move top layout around.
now problem have can not size of bitmap loaded in bottom imageview.
i have tried following:
displaymetrics om = new displaymetrics(); getwindowmanager().getdefaultdisplay().getmetrics(om); tv.settext("w:" + b.getscaledwidth(om) + " h:" + b.getscaledheight(om));
but won't work, b.getscaledwidth(om) returns actual width of bitmap , not 1 on screen, should (in case of landscape image) 480px, size of screen of phone testing on.
additional info: why need because image show in bottom imageview not of same proportions imageview. can size of imageview imageview larger image itself. need keep top imageview inside boundaries of image shown in bottom imageview need know size of image in bottom imageview , not size of bottom view itself.
any ideas doing wrong?
i did not find way did "manually".
i extended imageview class myimageview class , in onmeasure override have calculated scale factor , accordingly created rect representing boundaries in coordinates according relativelayout, inside of myimageview.
i went way because found post here referred creating own imageview class, can't find link anymore.
anyway, after check top/left positioning of top imageview , set maximum location while moving around in ontouch method.
Comments
Post a Comment