Created
April 1, 2014 18:22
-
-
Save rongi/9919963 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onLayout(boolean changed, int l, int t, int r, int b) { | |
final int width = r - l; | |
final int height = b - t; | |
final int bigImageViewHeight = Math.round(0.4f * height); | |
layoutChild(bigImageView, | |
Math.round(0.1f * width), | |
0, | |
Math.round(0.8f * width), | |
bigImageViewHeight); | |
final int bigImageViewCenterVertical = bigImageViewHeight / 2; | |
final int smallImageViewHeight = smallImageView.getMeasuredHeight(); // for example | |
layoutChild(smallImageView, | |
Math.round(0.3f * width), | |
bigImageViewCenterVertical - smallImageViewHeight / 2, | |
Math.round(0.4f * width), | |
smallImageViewHeight); | |
// etc | |
} | |
private static void layoutChild(View view, int left, int top, int width, int height) { | |
view.layout(left, top, left + width, top + height); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment