Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: How do I align textview on a image background that dos not strech in xml
    primarykey
    data
    text
    <p>Ok here is the problem... I have a image background that need some text and additional graphics on it. The background image needs to be in the center of the screen and may not stretch. Here is what i need to do:</p> <p><img src="https://i.stack.imgur.com/MWJiO.png" alt="enter image description here"></p> <p>The problem is that i need to align the text to the background image. I've tried to wrap it all into a relative layout - something like this:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/bg_image" android:layout_centerInParent="true" android:src="@drawable/member_card"/&gt; &lt;TextView android:layout_height="wrap_content" android:layout_alignLeft="@id/bg_image" android:text="@string/membercard_info" android:layout_marginTop="40dp" /&gt; &lt;TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignLeft="@id/bg_image" android:layout_marginTop="200dp" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>This will not work since android adds additional padding to the image to avoid it from stretching. Here is what happens in two different cases: <img src="https://i.stack.imgur.com/iXZQ9.png" alt="enter image description here"><img src="https://i.stack.imgur.com/OtmVO.png" alt="enter image description here"></p> <p>So how do I align the text to the background image?</p> <p>I've solved this problem in the past in code by baking it all into one image,- but would like to do this in xml. </p>
    singulars
    1. This table or related slice is empty.
    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.
 

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