public static PercentLayoutHelper.PercentLayoutInfo getPercentLayoutInfo( Context context, AttributeSet attrs) { PercentLayoutHelper.PercentLayoutInfo info = null; TypedArray array = context.obtainStyledAttributes(attrs, styleable.PercentLayout_Layout); float value = array.getFraction(styleable.PercentLayout_Layout_layout_widthPercent, 1, 1, -1.0F); if (value != -1.0F) { if (Log.isLoggable("PercentLayout", 2)) { Log.v("PercentLayout", "percent width: " + value); } info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo(); info.widthPercent = value; } value = array.getFraction(styleable.PercentLayout_Layout_layout_heightPercent, 1, 1, -1.0F); if (value != -1.0F) { if (Log.isLoggable("PercentLayout", 2)) { Log.v("PercentLayout", "percent height: " + value); } info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo(); info.heightPercent = value; } value = array.getFraction(styleable.PercentLayout_Layout_layout_marginPercent, 1, 1, -1.0F); if (value != -1.0F) { if (Log.isLoggable("PercentLayout", 2)) { Log.v("PercentLayout", "percent margin: " + value); } info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo(); info.leftMarginPercent = value; info.topMarginPercent = value; info.rightMarginPercent = value; info.bottomMarginPercent = value; } value = array.getFraction(styleable.PercentLayout_Layout_layout_marginLeftPercent, 1, 1, -1.0F); if (value != -1.0F) { if (Log.isLoggable("PercentLayout", 2)) { Log.v("PercentLayout", "percent left margin: " + value); } info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo(); info.leftMarginPercent = value; } value = array.getFraction(styleable.PercentLayout_Layout_layout_marginTopPercent, 1, 1, -1.0F); if (value != -1.0F) { if (Log.isLoggable("PercentLayout", 2)) { Log.v("PercentLayout", "percent top margin: " + value); } info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo(); info.topMarginPercent = value; } value = array.getFraction(styleable.PercentLayout_Layout_layout_marginRightPercent, 1, 1, -1.0F); if (value != -1.0F) { if (Log.isLoggable("PercentLayout", 2)) { Log.v("PercentLayout", "percent right margin: " + value); } info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo(); info.rightMarginPercent = value; } value = array.getFraction(styleable.PercentLayout_Layout_layout_marginBottomPercent, 1, 1, -1.0F); if (value != -1.0F) { if (Log.isLoggable("PercentLayout", 2)) { Log.v("PercentLayout", "percent bottom margin: " + value); } info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo(); info.bottomMarginPercent = value; } value = array.getFraction(styleable.PercentLayout_Layout_layout_marginStartPercent, 1, 1, -1.0F); if (value != -1.0F) { if (Log.isLoggable("PercentLayout", 2)) { Log.v("PercentLayout", "percent start margin: " + value); } info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo(); info.startMarginPercent = value; } value = array.getFraction(styleable.PercentLayout_Layout_layout_marginEndPercent, 1, 1, -1.0F); if (value != -1.0F) { if (Log.isLoggable("PercentLayout", 2)) { Log.v("PercentLayout", "percent end margin: " + value); } info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo(); info.endMarginPercent = value; } array.recycle(); if (Log.isLoggable("PercentLayout", 3)) { Log.d("PercentLayout", "constructed: " + info); } return info; }