Merge "Fix default gravity value for FrameLayout.LayoutParams" into nyc-dev
am: 1722613
* commit '1722613b0cc058523d525d3ca63cfc0a7c54b8aa':
Fix default gravity value for FrameLayout.LayoutParams
Change-Id: Ib151ce925ca0a07e7bd312fd67cba5b38a28219b
This commit is contained in:
@@ -16,17 +16,15 @@
|
||||
|
||||
package android.widget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.android.internal.R;
|
||||
|
||||
import android.annotation.AttrRes;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.StyleRes;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
@@ -36,8 +34,7 @@ import android.view.ViewGroup;
|
||||
import android.view.ViewHierarchyEncoder;
|
||||
import android.widget.RemoteViews.RemoteView;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* FrameLayout is designed to block out an area on the screen to display
|
||||
@@ -75,31 +72,29 @@ public class FrameLayout extends ViewGroup {
|
||||
@ViewDebug.ExportedProperty(category = "padding")
|
||||
private int mForegroundPaddingBottom = 0;
|
||||
|
||||
private final Rect mSelfBounds = new Rect();
|
||||
private final Rect mOverlayBounds = new Rect();
|
||||
|
||||
private final ArrayList<View> mMatchParentChildren = new ArrayList<View>(1);
|
||||
|
||||
public FrameLayout(Context context) {
|
||||
private final ArrayList<View> mMatchParentChildren = new ArrayList<>(1);
|
||||
|
||||
public FrameLayout(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public FrameLayout(Context context, @Nullable AttributeSet attrs) {
|
||||
|
||||
public FrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public FrameLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
public FrameLayout(@NonNull Context context, @Nullable AttributeSet attrs,
|
||||
@AttrRes int defStyleAttr) {
|
||||
this(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
public FrameLayout(
|
||||
Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
public FrameLayout(@NonNull Context context, @Nullable AttributeSet attrs,
|
||||
@AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(
|
||||
attrs, com.android.internal.R.styleable.FrameLayout, defStyleAttr, defStyleRes);
|
||||
|
||||
if (a.getBoolean(com.android.internal.R.styleable.FrameLayout_measureAllChildren, false)) {
|
||||
attrs, R.styleable.FrameLayout, defStyleAttr, defStyleRes);
|
||||
|
||||
if (a.getBoolean(R.styleable.FrameLayout_measureAllChildren, false)) {
|
||||
setMeasureAllChildren(true);
|
||||
}
|
||||
|
||||
@@ -171,10 +166,6 @@ public class FrameLayout extends ViewGroup {
|
||||
mPaddingBottom + mForegroundPaddingBottom;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int count = getChildCount();
|
||||
@@ -264,17 +255,13 @@ public class FrameLayout extends ViewGroup {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
layoutChildren(left, top, right, bottom, false /* no force left gravity */);
|
||||
}
|
||||
|
||||
void layoutChildren(int left, int top, int right, int bottom,
|
||||
boolean forceLeftGravity) {
|
||||
void layoutChildren(int left, int top, int right, int bottom, boolean forceLeftGravity) {
|
||||
final int count = getChildCount();
|
||||
|
||||
final int parentLeft = getPaddingLeftWithForeground();
|
||||
@@ -378,12 +365,9 @@ public class FrameLayout extends ViewGroup {
|
||||
return mMeasureAllChildren;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public LayoutParams generateLayoutParams(AttributeSet attrs) {
|
||||
return new FrameLayout.LayoutParams(getContext(), attrs);
|
||||
return new FrameLayout.LayoutParams(getContext(), attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -391,9 +375,6 @@ public class FrameLayout extends ViewGroup {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
|
||||
return p instanceof LayoutParams;
|
||||
@@ -431,34 +412,30 @@ public class FrameLayout extends ViewGroup {
|
||||
* Per-child layout information for layouts that support margins.
|
||||
* See {@link android.R.styleable#FrameLayout_Layout FrameLayout Layout Attributes}
|
||||
* for a list of all child view attributes that this class supports.
|
||||
*
|
||||
*
|
||||
* @attr ref android.R.styleable#FrameLayout_Layout_layout_gravity
|
||||
*/
|
||||
public static class LayoutParams extends MarginLayoutParams {
|
||||
/**
|
||||
* The gravity to apply with the View to which these layout parameters
|
||||
* are associated.
|
||||
* <p>
|
||||
* The default value is {@code Gravity.TOP | Gravity.START}
|
||||
*
|
||||
* @see android.view.Gravity
|
||||
*
|
||||
* @attr ref android.R.styleable#FrameLayout_Layout_layout_gravity
|
||||
*/
|
||||
public int gravity = -1;
|
||||
public int gravity = DEFAULT_CHILD_GRAVITY;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public LayoutParams(Context c, AttributeSet attrs) {
|
||||
public LayoutParams(@NonNull Context c, @Nullable AttributeSet attrs) {
|
||||
super(c, attrs);
|
||||
|
||||
TypedArray a = c.obtainStyledAttributes(attrs, com.android.internal.R.styleable.FrameLayout_Layout);
|
||||
gravity = a.getInt(com.android.internal.R.styleable.FrameLayout_Layout_layout_gravity, -1);
|
||||
final TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.FrameLayout_Layout);
|
||||
gravity = a.getInt(R.styleable.FrameLayout_Layout_layout_gravity,
|
||||
DEFAULT_CHILD_GRAVITY);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public LayoutParams(int width, int height) {
|
||||
super(width, height);
|
||||
}
|
||||
@@ -468,9 +445,9 @@ public class FrameLayout extends ViewGroup {
|
||||
* and weight.
|
||||
*
|
||||
* @param width the width, either {@link #MATCH_PARENT},
|
||||
* {@link #WRAP_CONTENT} or a fixed size in pixels
|
||||
* {@link #WRAP_CONTENT} or a fixed size in pixels
|
||||
* @param height the height, either {@link #MATCH_PARENT},
|
||||
* {@link #WRAP_CONTENT} or a fixed size in pixels
|
||||
* {@link #WRAP_CONTENT} or a fixed size in pixels
|
||||
* @param gravity the gravity
|
||||
*
|
||||
* @see android.view.Gravity
|
||||
@@ -480,17 +457,11 @@ public class FrameLayout extends ViewGroup {
|
||||
this.gravity = gravity;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public LayoutParams(ViewGroup.LayoutParams source) {
|
||||
public LayoutParams(@NonNull ViewGroup.LayoutParams source) {
|
||||
super(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public LayoutParams(ViewGroup.MarginLayoutParams source) {
|
||||
public LayoutParams(@NonNull ViewGroup.MarginLayoutParams source) {
|
||||
super(source);
|
||||
}
|
||||
|
||||
@@ -500,7 +471,7 @@ public class FrameLayout extends ViewGroup {
|
||||
*
|
||||
* @param source The layout params to copy from.
|
||||
*/
|
||||
public LayoutParams(LayoutParams source) {
|
||||
public LayoutParams(@NonNull LayoutParams source) {
|
||||
super(source);
|
||||
|
||||
this.gravity = source.gravity;
|
||||
|
||||
Reference in New Issue
Block a user