mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Add layout params copy constructors
This commit is contained in:
@@ -29,6 +29,39 @@ public class CommonLayoutParams extends FrameLayout.LayoutParams {
|
|||||||
super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.FILL);
|
super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommonLayoutParams(ViewGroup.LayoutParams source) {
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommonLayoutParams(ViewGroup.MarginLayoutParams source) {
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommonLayoutParams(FrameLayout.LayoutParams source) {
|
||||||
|
super((ViewGroup.MarginLayoutParams) source);
|
||||||
|
this.gravity = source.gravity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommonLayoutParams(CommonLayoutParams source) {
|
||||||
|
this((FrameLayout.LayoutParams) source);
|
||||||
|
|
||||||
|
this.widthPercent = source.widthPercent;
|
||||||
|
this.heightPercent = source.heightPercent;
|
||||||
|
|
||||||
|
this.topMargin = source.topMargin;
|
||||||
|
this.leftMargin = source.leftMargin;
|
||||||
|
this.bottomMargin = source.bottomMargin;
|
||||||
|
this.rightMargin = source.rightMargin;
|
||||||
|
|
||||||
|
this.left = source.left;
|
||||||
|
this.top = source.top;
|
||||||
|
this.row = source.row;
|
||||||
|
this.column = source.column;
|
||||||
|
this.rowSpan = source.rowSpan;
|
||||||
|
this.columnSpan = source.columnSpan;
|
||||||
|
this.dock = source.dock;
|
||||||
|
}
|
||||||
|
|
||||||
public float widthPercent = 0;
|
public float widthPercent = 0;
|
||||||
public float heightPercent = 0;
|
public float heightPercent = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import android.util.AttributeSet;
|
|||||||
import android.util.SparseIntArray;
|
import android.util.SparseIntArray;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
@@ -2221,8 +2222,20 @@ public class FlexboxLayout extends ViewGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
|
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams from) {
|
||||||
return new FlexboxLayout.LayoutParams();
|
if (from instanceof FlexboxLayout.LayoutParams)
|
||||||
|
return new FlexboxLayout.LayoutParams((FlexboxLayout.LayoutParams)from);
|
||||||
|
|
||||||
|
if (from instanceof CommonLayoutParams)
|
||||||
|
return new FlexboxLayout.LayoutParams((CommonLayoutParams)from);
|
||||||
|
|
||||||
|
if (from instanceof FrameLayout.LayoutParams)
|
||||||
|
return new FlexboxLayout.LayoutParams((FrameLayout.LayoutParams)from);
|
||||||
|
|
||||||
|
if (from instanceof ViewGroup.MarginLayoutParams)
|
||||||
|
return new FlexboxLayout.LayoutParams((ViewGroup.MarginLayoutParams)from);
|
||||||
|
|
||||||
|
return new FlexboxLayout.LayoutParams(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FlexDirection
|
@FlexDirection
|
||||||
@@ -2631,6 +2644,32 @@ public class FlexboxLayout extends ViewGroup {
|
|||||||
public LayoutParams() {
|
public LayoutParams() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LayoutParams(ViewGroup.LayoutParams source) {
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayoutParams(ViewGroup.MarginLayoutParams source) {
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayoutParams(FrameLayout.LayoutParams source) {
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayoutParams(CommonLayoutParams source) {
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayoutParams(LayoutParams source) {
|
||||||
|
super(source);
|
||||||
|
|
||||||
|
this.order = source.order;
|
||||||
|
this.flexGrow = source.flexGrow;
|
||||||
|
this.flexShrink = source.flexShrink;
|
||||||
|
this.wrapBefore = source.wrapBefore;
|
||||||
|
this.alignSelf = source.alignSelf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ import android.content.Context;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewParent;
|
import android.view.ViewParent;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hhristov
|
* @author hhristov
|
||||||
@@ -52,6 +54,41 @@ public class HorizontalScrollView extends android.widget.HorizontalScrollView {
|
|||||||
super.requestLayout();
|
super.requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommonLayoutParams generateDefaultLayoutParams() {
|
||||||
|
return new CommonLayoutParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CommonLayoutParams generateLayoutParams(AttributeSet attrs) {
|
||||||
|
return new CommonLayoutParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
|
||||||
|
return p instanceof CommonLayoutParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams from) {
|
||||||
|
if (from instanceof CommonLayoutParams)
|
||||||
|
return new CommonLayoutParams((CommonLayoutParams)from);
|
||||||
|
|
||||||
|
if (from instanceof FrameLayout.LayoutParams)
|
||||||
|
return new CommonLayoutParams((FrameLayout.LayoutParams)from);
|
||||||
|
|
||||||
|
if (from instanceof ViewGroup.MarginLayoutParams)
|
||||||
|
return new CommonLayoutParams((ViewGroup.MarginLayoutParams)from);
|
||||||
|
|
||||||
|
return new CommonLayoutParams(from);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void requestChildFocus(View child, View focused) {
|
public void requestChildFocus(View child, View focused) {
|
||||||
if (!mIsLayoutDirty) {
|
if (!mIsLayoutDirty) {
|
||||||
|
|||||||
@@ -42,8 +42,17 @@ public abstract class LayoutBase extends ViewGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LayoutParams generateLayoutParams(LayoutParams p) {
|
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams from) {
|
||||||
return new CommonLayoutParams();
|
if (from instanceof CommonLayoutParams)
|
||||||
|
return new CommonLayoutParams((CommonLayoutParams)from);
|
||||||
|
|
||||||
|
if (from instanceof FrameLayout.LayoutParams)
|
||||||
|
return new CommonLayoutParams((FrameLayout.LayoutParams)from);
|
||||||
|
|
||||||
|
if (from instanceof ViewGroup.MarginLayoutParams)
|
||||||
|
return new CommonLayoutParams((ViewGroup.MarginLayoutParams)from);
|
||||||
|
|
||||||
|
return new CommonLayoutParams(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ import org.nativescript.widgets.HorizontalScrollView.SavedState;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,6 +54,41 @@ public class VerticalScrollView extends ScrollView {
|
|||||||
super.requestLayout();
|
super.requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommonLayoutParams generateDefaultLayoutParams() {
|
||||||
|
return new CommonLayoutParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CommonLayoutParams generateLayoutParams(AttributeSet attrs) {
|
||||||
|
return new CommonLayoutParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
|
||||||
|
return p instanceof CommonLayoutParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams from) {
|
||||||
|
if (from instanceof CommonLayoutParams)
|
||||||
|
return new CommonLayoutParams((CommonLayoutParams)from);
|
||||||
|
|
||||||
|
if (from instanceof FrameLayout.LayoutParams)
|
||||||
|
return new CommonLayoutParams((FrameLayout.LayoutParams)from);
|
||||||
|
|
||||||
|
if (from instanceof ViewGroup.MarginLayoutParams)
|
||||||
|
return new CommonLayoutParams((ViewGroup.MarginLayoutParams)from);
|
||||||
|
|
||||||
|
return new CommonLayoutParams(from);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void requestChildFocus(View child, View focused) {
|
public void requestChildFocus(View child, View focused) {
|
||||||
if (!this.mIsLayoutDirty) {
|
if (!this.mIsLayoutDirty) {
|
||||||
|
|||||||
Reference in New Issue
Block a user