android ImageView scaling to fit another View
- by Nick
I have a relative layout that comprises a TextView and an ImageView:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:adjustViewBounds="true"/>
</RelativeLayout>
It looks as follows:
What I want to achieve is:
It means that I want my ImageView to scale to fit the TextView by height. Can it be done in xml, without java-coding?
If I could write something like
android:layout_height="match_that_TextView"
it would have solved this issue, but it's impossible I guess.