开发者

constrain dimension based on "other" dimension

开发者 https://www.devze.com 2023-03-20 11:11 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消