mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fixes
This commit is contained in:
@@ -26,7 +26,7 @@ public class CommonLayoutParams extends FrameLayout.LayoutParams {
|
|||||||
private static final StringBuilder sb = new StringBuilder();
|
private static final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
public CommonLayoutParams() {
|
public CommonLayoutParams() {
|
||||||
super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float widthPercent = 0;
|
public float widthPercent = 0;
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ class TabStrip extends LinearLayout {
|
|||||||
private final SimpleTabColorizer mDefaultTabColorizer;
|
private final SimpleTabColorizer mDefaultTabColorizer;
|
||||||
|
|
||||||
private int mDefaultTabTextColor;
|
private int mDefaultTabTextColor;
|
||||||
private Integer mTabTextColor;
|
private int mTabTextColor = -1;
|
||||||
private Integer mSelectedTabTextColor;
|
private int mSelectedTabTextColor = -1;
|
||||||
|
|
||||||
TabStrip(Context context) {
|
TabStrip(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
@@ -98,21 +98,21 @@ class TabStrip extends LinearLayout {
|
|||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTabTextColor(Integer color){
|
void setTabTextColor(int color){
|
||||||
mTabTextColor = color;
|
mTabTextColor = color;
|
||||||
updateTabsTextColor();
|
updateTabsTextColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer getTabTextColor(){
|
int getTabTextColor(){
|
||||||
return mTabTextColor;
|
return mTabTextColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSelectedTabTextColor(Integer color){
|
void setSelectedTabTextColor(int color){
|
||||||
mSelectedTabTextColor = color;
|
mSelectedTabTextColor = color;
|
||||||
updateTabsTextColor();
|
updateTabsTextColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer getSelectedTabTextColor(){
|
int getSelectedTabTextColor(){
|
||||||
return mSelectedTabTextColor;
|
return mSelectedTabTextColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ class TabStrip extends LinearLayout {
|
|||||||
LinearLayout linearLayout = (LinearLayout)getChildAt(i);
|
LinearLayout linearLayout = (LinearLayout)getChildAt(i);
|
||||||
TextView textView = (TextView)linearLayout.getChildAt(1);
|
TextView textView = (TextView)linearLayout.getChildAt(1);
|
||||||
if (i == mSelectedPosition){
|
if (i == mSelectedPosition){
|
||||||
if (mSelectedTabTextColor != null){
|
if (mSelectedTabTextColor >= 0){
|
||||||
textView.setTextColor(mSelectedTabTextColor);
|
textView.setTextColor(mSelectedTabTextColor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -130,7 +130,7 @@ class TabStrip extends LinearLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (mTabTextColor != null){
|
if (mTabTextColor >= 0){
|
||||||
textView.setTextColor(mTabTextColor);
|
textView.setTextColor(mTabTextColor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -11,383 +11,514 @@ import android.widget.FrameLayout;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class ViewHelper {
|
public class ViewHelper {
|
||||||
private ViewHelper() {
|
private ViewHelper() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static final int version = android.os.Build.VERSION.SDK_INT;
|
||||||
|
|
||||||
|
public static int getMinWidth(android.view.View view) {
|
||||||
|
return view.getMinimumWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMinWidth(android.view.View view, int value) {
|
||||||
|
view.setMinimumWidth(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMinHeight(android.view.View view) {
|
||||||
|
return view.getMinimumHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMinHeight(android.view.View view, int value) {
|
||||||
|
view.setMinimumHeight(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getWidth(android.view.View view) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
if (params != null) {
|
||||||
|
return params.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
static final int version = android.os.Build.VERSION.SDK_INT;
|
return ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
|
}
|
||||||
|
|
||||||
public static int getMinWidth(android.view.View view) {
|
public static void setWidth(android.view.View view, int value) {
|
||||||
return view.getMinimumWidth();
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
}
|
if (params == null) {
|
||||||
public static void setMinWidth(android.view.View view, int value) {
|
params = new CommonLayoutParams();
|
||||||
view.setMinimumWidth(value);
|
params.width = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMinHeight(android.view.View view) {
|
view.setLayoutParams(params);
|
||||||
return view.getMinimumHeight();
|
}
|
||||||
}
|
|
||||||
public static void setMinHeight(android.view.View view, int value) {
|
public static void setWidthPercent(android.view.View view, int value) {
|
||||||
view.setMinimumHeight(value);
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
if (params == null) {
|
||||||
|
CommonLayoutParams lp = new CommonLayoutParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getWidth(android.view.View view) {
|
if (params instanceof CommonLayoutParams) {
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
CommonLayoutParams lp = (CommonLayoutParams) params;
|
||||||
if (params != null) {
|
lp.widthPercent = value;
|
||||||
return params.width;
|
lp.width = (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||||
}
|
view.setLayoutParams(params);
|
||||||
|
|
||||||
return ViewGroup.LayoutParams.MATCH_PARENT;
|
|
||||||
}
|
}
|
||||||
public static void setWidth(android.view.View view, int value) {
|
}
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
|
||||||
if (params == null) {
|
|
||||||
params = new CommonLayoutParams();
|
|
||||||
params.width = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public static int getHeight(android.view.View view) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
if (params != null) {
|
||||||
|
return params.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setHeight(android.view.View view, int value) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
if (params == null) {
|
||||||
|
params = new CommonLayoutParams();
|
||||||
|
params.height = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
view.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setHeightPercent(android.view.View view, int value) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
if (params == null) {
|
||||||
|
CommonLayoutParams lp = new CommonLayoutParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params instanceof CommonLayoutParams) {
|
||||||
|
CommonLayoutParams lp = (CommonLayoutParams) params;
|
||||||
|
lp.heightPercent = value;
|
||||||
|
lp.height = (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.FILL_VERTICAL ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||||
|
view.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Rect getMargin(android.view.View view) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
if (params instanceof ViewGroup.MarginLayoutParams) {
|
||||||
|
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
||||||
|
return new Rect(lp.leftMargin, lp.topMargin, lp.rightMargin, lp.bottomMargin);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Rect();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMargin(android.view.View view, int left, int top, int right, int bottom) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
// Initialize if empty.
|
||||||
|
if (params == null) {
|
||||||
|
params = new CommonLayoutParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set margins only if params are of the correct type.
|
||||||
|
if (params instanceof ViewGroup.MarginLayoutParams) {
|
||||||
|
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
||||||
|
lp.leftMargin = left;
|
||||||
|
lp.topMargin = top;
|
||||||
|
lp.rightMargin = right;
|
||||||
|
lp.bottomMargin = bottom;
|
||||||
|
view.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMarginLeft(android.view.View view) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
if (params instanceof ViewGroup.MarginLayoutParams) {
|
||||||
|
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
||||||
|
return lp.leftMargin;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMarginLeft(android.view.View view, int value) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
// Initialize if empty.
|
||||||
|
if (params == null) {
|
||||||
|
params = new CommonLayoutParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set margins only if params are of the correct type.
|
||||||
|
if (params instanceof ViewGroup.MarginLayoutParams) {
|
||||||
|
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
||||||
|
lp.leftMargin = value;
|
||||||
view.setLayoutParams(params);
|
view.setLayoutParams(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getHeight(android.view.View view) {
|
if (params instanceof CommonLayoutParams) {
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
CommonLayoutParams lp = (CommonLayoutParams) params;
|
||||||
if (params != null) {
|
lp.leftMarginPercent = -1;
|
||||||
return params.height;
|
view.setLayoutParams(params);
|
||||||
}
|
|
||||||
|
|
||||||
return ViewGroup.LayoutParams.MATCH_PARENT;
|
|
||||||
}
|
}
|
||||||
public static void setHeight(android.view.View view, int value) {
|
}
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
|
||||||
if (params == null) {
|
|
||||||
params = new CommonLayoutParams();
|
|
||||||
params.height = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public static void setMarginLeftPercent(android.view.View view, int value) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
if (params == null) {
|
||||||
|
CommonLayoutParams lp = new CommonLayoutParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params instanceof CommonLayoutParams) {
|
||||||
|
CommonLayoutParams lp = (CommonLayoutParams) params;
|
||||||
|
lp.leftMargin = 0;
|
||||||
|
lp.leftMarginPercent = value;
|
||||||
|
view.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMarginTop(android.view.View view) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
if (params instanceof ViewGroup.MarginLayoutParams) {
|
||||||
|
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
||||||
|
return lp.topMargin;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMarginTop(android.view.View view, int value) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
// Initialize if empty.
|
||||||
|
if (params == null) {
|
||||||
|
params = new CommonLayoutParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set margins only if params are of the correct type.
|
||||||
|
if (params instanceof ViewGroup.MarginLayoutParams) {
|
||||||
|
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
||||||
|
lp.topMargin = value;
|
||||||
view.setLayoutParams(params);
|
view.setLayoutParams(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Rect getMargin(android.view.View view) {
|
if (params instanceof CommonLayoutParams) {
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
CommonLayoutParams lp = (CommonLayoutParams) params;
|
||||||
if (params instanceof ViewGroup.MarginLayoutParams) {
|
lp.topMarginPercent = -1;
|
||||||
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
view.setLayoutParams(params);
|
||||||
return new Rect(lp.leftMargin, lp.topMargin, lp.rightMargin, lp.bottomMargin);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Rect();
|
|
||||||
}
|
}
|
||||||
public static void setMargin(android.view.View view, int left, int top, int right, int bottom) {
|
}
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
|
||||||
// Initialize if empty.
|
|
||||||
if (params == null) {
|
|
||||||
params = new CommonLayoutParams();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set margins only if params are of the correct type.
|
public static void setMarginTopPercent(android.view.View view, int value) {
|
||||||
if (params instanceof ViewGroup.MarginLayoutParams) {
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
if (params == null) {
|
||||||
lp.leftMargin = left;
|
CommonLayoutParams lp = new CommonLayoutParams();
|
||||||
lp.topMargin = top;
|
|
||||||
lp.rightMargin = right;
|
|
||||||
lp.bottomMargin = bottom;
|
|
||||||
view.setLayoutParams(params);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMarginLeft(android.view.View view) {
|
if (params instanceof CommonLayoutParams) {
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
CommonLayoutParams lp = (CommonLayoutParams) params;
|
||||||
if (params instanceof ViewGroup.MarginLayoutParams) {
|
lp.topMargin = 0;
|
||||||
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
lp.topMarginPercent = value;
|
||||||
return lp.leftMargin;
|
view.setLayoutParams(params);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
public static void setMarginLeft(android.view.View view, int value) {
|
}
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
|
||||||
// Initialize if empty.
|
|
||||||
if (params == null) {
|
|
||||||
params = new CommonLayoutParams();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set margins only if params are of the correct type.
|
public static int getMarginRight(android.view.View view) {
|
||||||
if (params instanceof ViewGroup.MarginLayoutParams) {
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
if (params instanceof ViewGroup.MarginLayoutParams) {
|
||||||
lp.leftMargin = value;
|
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
||||||
view.setLayoutParams(params);
|
return lp.rightMargin;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMarginTop(android.view.View view) {
|
return 0;
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
}
|
||||||
if (params instanceof ViewGroup.MarginLayoutParams) {
|
|
||||||
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
|
||||||
return lp.topMargin;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
public static void setMarginRight(android.view.View view, int value) {
|
||||||
}
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
public static void setMarginTop(android.view.View view, int value) {
|
// Initialize if empty.
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
if (params == null) {
|
||||||
// Initialize if empty.
|
params = new CommonLayoutParams();
|
||||||
if (params == null) {
|
|
||||||
params = new CommonLayoutParams();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set margins only if params are of the correct type.
|
|
||||||
if (params instanceof ViewGroup.MarginLayoutParams) {
|
|
||||||
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
|
||||||
lp.topMargin = value;
|
|
||||||
view.setLayoutParams(params);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMarginRight(android.view.View view) {
|
// Set margins only if params are of the correct type.
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
if (params instanceof ViewGroup.MarginLayoutParams) {
|
||||||
if (params instanceof ViewGroup.MarginLayoutParams) {
|
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
||||||
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
lp.rightMargin = value;
|
||||||
return lp.rightMargin;
|
view.setLayoutParams(params);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
public static void setMarginRight(android.view.View view, int value) {
|
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
|
||||||
// Initialize if empty.
|
|
||||||
if (params == null) {
|
|
||||||
params = new CommonLayoutParams();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set margins only if params are of the correct type.
|
|
||||||
if (params instanceof ViewGroup.MarginLayoutParams) {
|
|
||||||
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
|
||||||
lp.rightMargin = value;
|
|
||||||
view.setLayoutParams(params);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMarginBottom(android.view.View view) {
|
if (params instanceof CommonLayoutParams) {
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
CommonLayoutParams lp = (CommonLayoutParams) params;
|
||||||
if (params instanceof ViewGroup.MarginLayoutParams) {
|
lp.rightMarginPercent = -1;
|
||||||
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
view.setLayoutParams(params);
|
||||||
return lp.bottomMargin;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
public static void setMarginBottom(android.view.View view, int value) {
|
}
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
|
||||||
// Initialize if empty.
|
|
||||||
if (params == null) {
|
|
||||||
params = new CommonLayoutParams();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set margins only if params are of the correct type.
|
public static void setMarginRightPercent(android.view.View view, int value) {
|
||||||
if (params instanceof ViewGroup.MarginLayoutParams) {
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
if (params == null) {
|
||||||
lp.bottomMargin = value;
|
CommonLayoutParams lp = new CommonLayoutParams();
|
||||||
view.setLayoutParams(params);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getHorizontalAlighment(android.view.View view) {
|
if (params instanceof CommonLayoutParams) {
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
CommonLayoutParams lp = (CommonLayoutParams) params;
|
||||||
if (params instanceof FrameLayout.LayoutParams) {
|
lp.rightMargin = 0;
|
||||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
lp.rightMarginPercent = value;
|
||||||
if (Gravity.isHorizontal(lp.gravity)) {
|
view.setLayoutParams(params);
|
||||||
switch (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
|
}
|
||||||
case Gravity.LEFT:
|
}
|
||||||
return "left";
|
|
||||||
case Gravity.CENTER:
|
public static int getMarginBottom(android.view.View view) {
|
||||||
return "center";
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
case Gravity.RIGHT:
|
if (params instanceof ViewGroup.MarginLayoutParams) {
|
||||||
return "right";
|
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
||||||
case Gravity.FILL_HORIZONTAL:
|
return lp.bottomMargin;
|
||||||
return "stretch";
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMarginBottom(android.view.View view, int value) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
// Initialize if empty.
|
||||||
|
if (params == null) {
|
||||||
|
params = new CommonLayoutParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set margins only if params are of the correct type.
|
||||||
|
if (params instanceof ViewGroup.MarginLayoutParams) {
|
||||||
|
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) params;
|
||||||
|
lp.bottomMargin = value;
|
||||||
|
view.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params instanceof CommonLayoutParams) {
|
||||||
|
CommonLayoutParams lp = (CommonLayoutParams) params;
|
||||||
|
lp.bottomMarginPercent = -1;
|
||||||
|
view.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMarginBottomPercent(android.view.View view, int value) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
if (params == null) {
|
||||||
|
CommonLayoutParams lp = new CommonLayoutParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params instanceof CommonLayoutParams) {
|
||||||
|
CommonLayoutParams lp = (CommonLayoutParams) params;
|
||||||
|
lp.bottomMargin = 0;
|
||||||
|
lp.bottomMarginPercent = value;
|
||||||
|
view.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getHorizontalAlignment(android.view.View view) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
if (params instanceof FrameLayout.LayoutParams) {
|
||||||
|
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
||||||
|
if (Gravity.isHorizontal(lp.gravity)) {
|
||||||
|
switch (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
|
||||||
|
case Gravity.LEFT:
|
||||||
|
return "left";
|
||||||
|
case Gravity.CENTER:
|
||||||
|
return "center";
|
||||||
|
case Gravity.RIGHT:
|
||||||
|
return "right";
|
||||||
|
case Gravity.FILL_HORIZONTAL:
|
||||||
|
return "stretch";
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "stretch";
|
|
||||||
}
|
|
||||||
public static void setHorizontalAlighment(android.view.View view, String value) {
|
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
|
||||||
// Initialize if empty.
|
|
||||||
if (params == null) {
|
|
||||||
params = new CommonLayoutParams();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set margins only if params are of the correct type.
|
|
||||||
if (params instanceof FrameLayout.LayoutParams) {
|
|
||||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
|
||||||
switch (value) {
|
|
||||||
case "left":
|
|
||||||
lp.gravity = Gravity.LEFT | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
|
||||||
break;
|
|
||||||
case "center":
|
|
||||||
lp.gravity = Gravity.CENTER_HORIZONTAL | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
|
||||||
break;
|
|
||||||
case "right":
|
|
||||||
lp.gravity = Gravity.RIGHT | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
|
||||||
break;
|
|
||||||
case "stretch":
|
|
||||||
lp.gravity = Gravity.FILL_HORIZONTAL | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
view.setLayoutParams(params);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getVerticalAlignment(android.view.View view) {
|
return "stretch";
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
}
|
||||||
if (params instanceof FrameLayout.LayoutParams) {
|
|
||||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
public static void setHorizontalAlignment(android.view.View view, String value) {
|
||||||
if (Gravity.isHorizontal(lp.gravity)) {
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
switch (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK) {
|
// Initialize if empty.
|
||||||
case Gravity.TOP:
|
if (params == null) {
|
||||||
return "top";
|
params = new CommonLayoutParams();
|
||||||
case Gravity.CENTER:
|
}
|
||||||
return "center";
|
|
||||||
case Gravity.BOTTOM:
|
// Set margins only if params are of the correct type.
|
||||||
return "bottom";
|
if (params instanceof FrameLayout.LayoutParams) {
|
||||||
case Gravity.FILL_VERTICAL:
|
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
||||||
return "stretch";
|
switch (value) {
|
||||||
|
case "left":
|
||||||
|
lp.gravity = Gravity.LEFT | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
||||||
|
break;
|
||||||
|
case "center":
|
||||||
|
case "middle":
|
||||||
|
lp.gravity = Gravity.CENTER_HORIZONTAL | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
||||||
|
break;
|
||||||
|
case "right":
|
||||||
|
lp.gravity = Gravity.RIGHT | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
||||||
|
break;
|
||||||
|
case "stretch":
|
||||||
|
lp.gravity = Gravity.FILL_HORIZONTAL | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
view.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getVerticalAlignment(android.view.View view) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
if (params instanceof FrameLayout.LayoutParams) {
|
||||||
|
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
||||||
|
if (Gravity.isHorizontal(lp.gravity)) {
|
||||||
|
switch (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK) {
|
||||||
|
case Gravity.TOP:
|
||||||
|
return "top";
|
||||||
|
case Gravity.CENTER:
|
||||||
|
return "center";
|
||||||
|
case Gravity.BOTTOM:
|
||||||
|
return "bottom";
|
||||||
|
case Gravity.FILL_VERTICAL:
|
||||||
|
return "stretch";
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "stretch";
|
|
||||||
}
|
}
|
||||||
public static void setVerticalAlignment(android.view.View view, String value){
|
|
||||||
ViewGroup.LayoutParams params = view.getLayoutParams();
|
return "stretch";
|
||||||
// Initialize if empty.
|
}
|
||||||
if (params == null) {
|
|
||||||
params = new CommonLayoutParams();
|
public static void setVerticalAlignment(android.view.View view, String value) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
// Initialize if empty.
|
||||||
|
if (params == null) {
|
||||||
|
params = new CommonLayoutParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set margins only if params are of the correct type.
|
||||||
|
if (params instanceof FrameLayout.LayoutParams) {
|
||||||
|
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
||||||
|
switch (value) {
|
||||||
|
case "top":
|
||||||
|
lp.gravity = Gravity.TOP | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
||||||
|
break;
|
||||||
|
case "center":
|
||||||
|
case "middle":
|
||||||
|
lp.gravity = Gravity.CENTER_VERTICAL | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
||||||
|
break;
|
||||||
|
case "bottom":
|
||||||
|
lp.gravity = Gravity.BOTTOM | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
||||||
|
break;
|
||||||
|
case "stretch":
|
||||||
|
lp.gravity = Gravity.FILL_VERTICAL | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
view.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set margins only if params are of the correct type.
|
public static Rect getPadding(android.view.View view) {
|
||||||
if (params instanceof FrameLayout.LayoutParams) {
|
return new Rect(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
|
||||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
}
|
||||||
switch (value) {
|
|
||||||
case "top":
|
public static void setPadding(android.view.View view, int left, int top, int right, int bottom) {
|
||||||
lp.gravity = Gravity.TOP | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
view.setPadding(left, top, right, bottom);
|
||||||
break;
|
}
|
||||||
case "center":
|
|
||||||
lp.gravity = Gravity.CENTER_VERTICAL | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
public static int getPaddingLeft(android.view.View view) {
|
||||||
break;
|
return view.getPaddingLeft();
|
||||||
case "bottom":
|
}
|
||||||
lp.gravity = Gravity.BOTTOM| (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
|
||||||
break;
|
public static void setPaddingLeft(android.view.View view, int value) {
|
||||||
case "stretch":
|
view.setPadding(value, view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
|
||||||
lp.gravity = Gravity.FILL_VERTICAL | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
}
|
||||||
break;
|
|
||||||
}
|
public static int getPaddingTop(android.view.View view) {
|
||||||
view.setLayoutParams(params);
|
return view.getPaddingTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setPaddingTop(android.view.View view, int value) {
|
||||||
|
view.setPadding(view.getPaddingLeft(), value, view.getPaddingRight(), view.getPaddingBottom());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPaddingRight(android.view.View view) {
|
||||||
|
return view.getPaddingRight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setPaddingRight(android.view.View view, int value) {
|
||||||
|
view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), value, view.getPaddingBottom());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getPaddingBottom(android.view.View view) {
|
||||||
|
return view.getPaddingBottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setPaddingBottom(android.view.View view, int value) {
|
||||||
|
view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getRotate(android.view.View view) {
|
||||||
|
return view.getRotation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setRotate(android.view.View view, float value) {
|
||||||
|
view.setRotation(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getScaleX(android.view.View view) {
|
||||||
|
return view.getScaleX();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setScaleX(android.view.View view, float value) {
|
||||||
|
view.setScaleX(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getScaleY(android.view.View view) {
|
||||||
|
return view.getScaleY();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setScaleY(android.view.View view, float value) {
|
||||||
|
view.setScaleY(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getTranslateX(android.view.View view) {
|
||||||
|
return view.getTranslationX();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setTranslateX(android.view.View view, float value) {
|
||||||
|
view.setTranslationX(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getTranslateY(android.view.View view) {
|
||||||
|
return view.getTranslationY();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setTranslateY(android.view.View view, float value) {
|
||||||
|
view.setTranslationY(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TargetApi(21)
|
||||||
|
public static float getZIndex(android.view.View view) {
|
||||||
|
if (ViewHelper.version >= 21) {
|
||||||
|
return view.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Rect getPadding(android.view.View view) {
|
return 0;
|
||||||
return new Rect(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
|
}
|
||||||
|
|
||||||
|
@TargetApi(21)
|
||||||
|
public static void setZIndex(android.view.View view, float value) {
|
||||||
|
if (ViewHelper.version >= 21) {
|
||||||
|
view.setZ(value);
|
||||||
}
|
}
|
||||||
public static void setPadding(android.view.View view, int left, int top, int right, int bottom) {
|
}
|
||||||
view.setPadding(left, top, right, bottom);
|
|
||||||
|
@TargetApi(21)
|
||||||
|
public static float getLetterspacing(android.widget.TextView textView) {
|
||||||
|
if (ViewHelper.version >= 21) {
|
||||||
|
return textView.getLetterSpacing();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getPaddingLeft(android.view.View view) {
|
return 0;
|
||||||
return view.getPaddingLeft();
|
}
|
||||||
}
|
|
||||||
public static void setPaddingLeft(android.view.View view, int value) {
|
|
||||||
view.setPadding(value, view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getPaddingTop(android.view.View view) {
|
@TargetApi(21)
|
||||||
return view.getPaddingTop();
|
public static void setLetterspacing(android.widget.TextView textView, float value) {
|
||||||
}
|
if (ViewHelper.version >= 21) {
|
||||||
public static void setPaddingTop(android.view.View view, int value) {
|
textView.setLetterSpacing(value);
|
||||||
view.setPadding(view.getPaddingLeft(), value, view.getPaddingRight(), view.getPaddingBottom());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getPaddingRight(android.view.View view) {
|
|
||||||
return view.getPaddingRight();
|
|
||||||
}
|
|
||||||
public static void setPaddingRight(android.view.View view, int value) {
|
|
||||||
view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), value, view.getPaddingBottom());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getPaddingBottom(android.view.View view) {
|
|
||||||
return view.getPaddingBottom();
|
|
||||||
}
|
|
||||||
public static void setPaddingBottom(android.view.View view, int value) {
|
|
||||||
view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getRotate(android.view.View view) {
|
|
||||||
return view.getRotation();
|
|
||||||
}
|
|
||||||
public static void setRotate(android.view.View view, float value) {
|
|
||||||
view.setRotation(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getScaleX(android.view.View view) {
|
|
||||||
return view.getScaleX();
|
|
||||||
}
|
|
||||||
public static void setScaleX(android.view.View view, float value) {
|
|
||||||
view.setScaleX(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getScaleY(android.view.View view) {
|
|
||||||
return view.getScaleY();
|
|
||||||
}
|
|
||||||
public static void setScaleY(android.view.View view, float value) {
|
|
||||||
view.setScaleY(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getTranslateX(android.view.View view) {
|
|
||||||
return view.getTranslationX();
|
|
||||||
}
|
|
||||||
public static void setTranslateX(android.view.View view, float value) {
|
|
||||||
view.setTranslationX(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getTranslateY(android.view.View view) {
|
|
||||||
return view.getTranslationY();
|
|
||||||
}
|
|
||||||
public static void setTranslateY(android.view.View view, float value) {
|
|
||||||
view.setTranslationY(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(21)
|
|
||||||
public static float getZIndex(android.view.View view) {
|
|
||||||
if (ViewHelper.version >= 21) {
|
|
||||||
return view.getZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(21)
|
|
||||||
public static void setZIndex(android.view.View view, float value) {
|
|
||||||
if (ViewHelper.version >= 21) {
|
|
||||||
view.setZ(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(21)
|
|
||||||
public static float getLetterspacing(android.widget.TextView textView) {
|
|
||||||
if (ViewHelper.version >= 21) {
|
|
||||||
return textView.getLetterSpacing();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(21)
|
|
||||||
public static void setLetterspacing(android.widget.TextView textView, float value) {
|
|
||||||
if (ViewHelper.version >= 21) {
|
|
||||||
textView.setLetterSpacing(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user