right, int bottom) { MarginLayoutParams layoutParams = (MarginLayoutParams) icon.getLayoutParams(); // Figure out the x-coordinate and y-coordinate of the icon. int x = getPaddingLeft() + layoutParams.leftMargin; int y = getPaddingTop() + layoutParams.topMargin; // Layout the icon. icon.layout(x, y, x + icon.getMeasuredWidth(), y + icon.getMeasuredHeight()); // Calculate the x-coordinate of the title: icon's right coordinate + // the icon's right margin. x += icon.getMeasuredWidth() + layoutParams.rightMargin; // Add in the title's left margin. layoutParams = (MarginLayoutParams) titleView.getLayoutParams(); x += layoutParams.leftMargin; // Calculate the y-coordinate of the title: this ViewGroup's top padding + // the title's top margin y = getPaddingTop() + layoutParams.topMargin; // Layout the title. titleView.layout(x, y, x + titleView.getMeasuredWidth(), y + titleView.getMeasuredHeight()); // The subtitle has the same x-coordinate as the title. So no more calculating there. // Calculate the y-coordinate of the subtitle: the title's bottom coordinate + // the title's bottom margin. y += titleView.getMeasuredHeight() + layoutParams.bottomMargin; layoutParams = (MarginLayoutParams) subtitleView.getLayoutParams(); // Add in the subtitle's top margin. y += layoutParams.topMargin; // Layout the subtitle. subtitleView.layout(x, y, x + subtitleView.getMeasuredWidth(), y + subtitleView.getMeasuredHeight()); }
= view.id // Initialize width and height of new view. constraintSet.constrainWidth(id, MATCH_CONSTRAINT) constraintSet.constrainHeight(id, rowHeight) // Constrain new view vertically. val target = if (lastRowId PARENT_ID) TOP else BOTTOM constraintSet.connect(id, TOP, lastRowId, target) 44
UI WITH CONSTRAINTLAYOUT developer.android.com/training/constraint-layout/index.html ANDROID DEVELOPERS BACKSTAGE: EPISODE 50: CONSTRAINT LAYOUT androidbackstage.blogspot.com/2016/06/episode-50-constraint-layout.html USING CONSTRAINTLAYOUT TO DESIGN YOUR VIEWS | CODE LABS codelabs.developers.google.com/codelabs/constraint-layout/index.html ANDROID LAYOUTS: A NEW WORLD | GOOGLE I/O 2016 https://youtu.be/sO9aX87hq9c CONSTRAINTLAYOUT https://speakerdeck.com/writtmeyer/constraintlayout-1 ADVANCED CONSTRAINTLAYOUT http://cfp.devoxx.us/2017/talk/XOD-8930/Advanced_ConstraintLayout
OUT: PART 1 http://wiresareobsolete.com/2016/07/constraintlayout-part-1/ SOME THOUGHTS ON ANDROID’S NEW CONSTRAINTLAYOUT AND ANDROID STUDIO’S NEW DESIGN EDITOR http://www.grokkingandroid.com/thoughts-on-constraintlayout-and-design-editor/ BUILD A UI WITH LAYOUT EDITOR developer.android.com/studio/write/layout-editor.html WHAT'S NEW IN ANDROID DEVELOPMENT TOOLS | GOOGLE I/O 2016 https://youtu.be/csaXml4xtN8 THE EXPERTS' GUIDE TO ANDROID DEVELOPMENT TOOLS | GOOGLE I/O 2016 https://youtu.be/hHnTIMjd1Y8