Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is a correct way to place image over ImageView?
    primarykey
    data
    text
    <p>I'm novice in android development and still can't understand fully how sizing works with different layouts. I want to place a preview of the book into this template:</p> <p><img src="https://i.stack.imgur.com/tXs55.png" alt="book_template"></p> <p>I've tried to implement it using FrameLayout. The idea is that the center of preview image will be exactly where the center of the png background is. Here is the code:</p> <pre><code>&lt;FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight=".5" &gt; &lt;ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/book_frame" /&gt; &lt;ImageView android:id="@+id/previewImage" android:layout_width="83dp" android:layout_height="83dp" android:layout_gravity="center_vertical|center_horizontal" android:src="@drawable/abs__ab_bottom_solid_dark_holo" /&gt; &lt;/FrameLayout&gt; </code></pre> <p>The result in layout builder look exactly like I want it to be:</p> <p><img src="https://i.stack.imgur.com/bwzZU.png" alt="emulator_result"></p> <p>On real phone it is different:</p> <p><img src="https://i.stack.imgur.com/gxC9D.png" alt="phone_result"></p> <p>I think on other resolutions it will also differ from both variants. So my question is how to synchronize these images so after any resizing and distortions the preview will fit the cover correctly? Possible solution would be to remove border from image and place it on previewImage instead. But there are several similar usecases in application where the border can't be removed, so I'd like to find out a universal solution for all of them.</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.
 

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