Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting bitmap size in pixels on screen, not the actual size?
    primarykey
    data
    text
    <p>I have a layout that has some horizontal scroll on top, some text box on the bottom and whatever space is left in the middle I fill it with an ImageView. In that ImageView I load a bitmap. Let's call this ImageView the <strong>bottom one</strong>.</p> <p>Now, on top of that ImageView I load dynamically another ImageView that the user can move about by dragging it. The second ImageView (<strong>top one</strong>) has a small icon in it that will be overlayed on top of my bitmap and saved. Think of it as a logo/watermark.</p> <p>Both ImageViews are in a RelativeLayout, so I can move the top layout around.</p> <p>Now the problem I have is that I can not get the size of the bitmap that is loaded in the <strong>bottom</strong> ImageView.</p> <p>I have tried the following:</p> <pre><code>DisplayMetrics om = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(om); tv.setText("W:" + b.getScaledWidth(om) + " H:" + b.getScaledHeight(om)); </code></pre> <p>but it won't work, <strong><em>b.getScaledWidth(om)</em></strong> returns the actual width of my bitmap and not the one on screen, which should be (in case of a landscape image) 480px, the size of the screen of the phone I am testing on.</p> <p>ADDITIONAL INFO: Why I need this is because the image I show in bottom ImageView is not of the same proportions as the ImageView. So I can get the size of the ImageView but this ImageView is larger then the image itself. As I need to keep the top ImageView inside the boundaries of image that is shown in bottom ImageView I need to know the size of the image in the bottom ImageView and not the size of the bottom View itself.</p> <p>Any ideas what am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload