约束基于维"其他"尺寸 [英] constrain dimension based on "other" dimension
本文介绍了约束基于维"其他"尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建使得维度之一是基于重量的图。不过,我想这种观点具有特定的纵横比。在这种情况下,我希望它是正方形。
I want to create a view such that one of the dimensions is based on a weight. However, I want that view to have a particular aspect ratio. In this case, i want it to be square.
所以我风有这样的事情:
So I wind up having something like this:
<ImageView
android:id="@+id/MyPicture"
android:layout_width="???"
android:layout_height="0"
android:layout_weight="2"
android:scaleType="fitXY"
android:src="@drawable/mypicture"/>
我怎样才能做到这一点?
How can I achieve this?
推荐答案
您会做在Java中code。有一个在XML没有办法指定一个维度是依赖于另一维度。
You would have to do that in Java code. There is no way in XML to specify one dimension is dependent upon another dimension.
这篇关于约束基于维&QUOT;其他&QUOT;尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文