开发者

How can I set the width and height of an ImageView to another ImageView's width and height on the XML?

I have this layout.

<ImageView
  android:id="@+id/icon"
  android:layout_gravity="left"
  android:layout_marginLeft="5px"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:src="@drawable/icon"/>

  <ImageView
  android:id="@+id/header_avatar"
  android:layout_gravity="left"
  android:layout_marginLeft="5px"
  android:layout_width="?????"
  android:layout_height="?????"/>

I want the second ImageView to have the very same size of the first ImageView so that 开发者_如何转开发it resizes the pictures I set in the second view (header_avatar) to the same of the first view (@drawable/icon). Is this posible or do I have to do it programmatically? Cannot I reference the first view's width and length on the second view?

Thanks in advance.


Using relative layouts could do the trick. If not, do it programatically in the onCreate method of your activity.


Use Styles. Define a style which fits both image views and assign it to both like in the example.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜