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);
|
||||
}
|
||||
|
||||
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 heightPercent = 0;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.util.AttributeSet;
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
@@ -2221,8 +2222,20 @@ public class FlexboxLayout extends ViewGroup {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
|
||||
return new FlexboxLayout.LayoutParams();
|
||||
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams from) {
|
||||
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
|
||||
@@ -2631,6 +2644,32 @@ public class FlexboxLayout extends ViewGroup {
|
||||
public LayoutParams() {
|
||||
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.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
/**
|
||||
* @author hhristov
|
||||
@@ -51,7 +53,42 @@ public class HorizontalScrollView extends android.widget.HorizontalScrollView {
|
||||
this.mIsLayoutDirty = true;
|
||||
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
|
||||
public void requestChildFocus(View child, View focused) {
|
||||
if (!mIsLayoutDirty) {
|
||||
@@ -179,7 +216,7 @@ public class HorizontalScrollView extends android.widget.HorizontalScrollView {
|
||||
ss.isLayoutRtl = this.isLayoutRtl();
|
||||
return ss;
|
||||
}
|
||||
|
||||
|
||||
private void scrollToChild(View child) {
|
||||
child.getDrawingRect(mTempRect);
|
||||
|
||||
|
||||
@@ -42,8 +42,17 @@ public abstract class LayoutBase extends ViewGroup {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LayoutParams generateLayoutParams(LayoutParams p) {
|
||||
return new CommonLayoutParams();
|
||||
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
|
||||
|
||||
@@ -7,7 +7,10 @@ import org.nativescript.widgets.HorizontalScrollView.SavedState;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Parcelable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
/**
|
||||
@@ -50,7 +53,42 @@ public class VerticalScrollView extends ScrollView {
|
||||
this.mIsLayoutDirty = true;
|
||||
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
|
||||
public void requestChildFocus(View child, View focused) {
|
||||
if (!this.mIsLayoutDirty) {
|
||||
|
||||
Reference in New Issue
Block a user