Note that there are some explanatory texts on larger screens.

plurals
  1. POLayout: how to make image to change its width and height proportionally?
    primarykey
    data
    text
    <p>I have such layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"&gt; &lt;TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/my_image" android:ellipsize="end" android:singleLine="true" android:text="Some text" android:textAppearance="?android:attr/textAppearanceMedium" /&gt; &lt;ImageView android:id="@+id/my_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/title" android:layout_alignBottom="@+id/title" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:adjustViewBounds="true" android:src="@drawable/my_bitmap_image" /&gt; </code></pre> <p></p> <p>This layout does almost what I need: it makes image view height the same as text view. The image graphic contents stretched also keeping aspect ratio. </p> <p><b>But, </b> the width of the image view does <b>not</b> change! As a result, I have a wide gap between text and the image view! As a temporal solution, I override <code>View#onLayout</code>. </p> <p><b>The question</b>: how to change image width in xml layout?</p> <p><b>UPDATE:</b></p> <p>This is a final layout I need (text + a few images). Look at the first image: its width should be exactly the same as scaled image in it with no paddings and margins:</p> <p><img src="https://i.stack.imgur.com/go0Ea.jpg" alt="enter image description here"></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.
 

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