我有一个相对布局,其中包括一个TextView和一个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>
它看起来如下:
我想要实现的是:
这意味着我希望我的ImageView按高度缩放以适应TextView。是否可以在xml中完成,而不需要使用Java编码? 如果我能写出类似于以下内容的东西
android:layout_height="match_that_TextView"
这可以解决这个问题,但我猜想这是不可能的。