constrain dimension based on "other" dimension
I want t开发者_Go百科o 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?
You would have to do that in Java code. There is no way in XML to specify one dimension is dependent upon another dimension.
精彩评论