List of usage examples for android.view View getLayoutParams
@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_") public ViewGroup.LayoutParams getLayoutParams()
From source file:Main.java
static int getMarginEnd(View v) { if (v == null) { return 0; }/*from w ww. j av a 2s. c o m*/ ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); return MarginLayoutParamsCompat.getMarginEnd(lp); }
From source file:Main.java
public static void moveByAmount(View viewToMove, int amount) { Integer viewHeight = viewToMove.getHeight(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) viewToMove.getLayoutParams(); if (params.topMargin + amount < viewHeight * -1) { params.topMargin = viewHeight * -1; } else if (params.topMargin + amount > 0) { params.topMargin = 0;//from www .j a v a2 s. c o m } else { params.topMargin = params.topMargin + amount; } viewToMove.setLayoutParams(params); viewToMove.requestLayout(); }
From source file:Main.java
public static int getViewWidth(View view) { if (view != null) { int width = view.getMeasuredWidth(); if (width == 0) { LayoutParams params = view.getLayoutParams(); if (params != null && params.width > 0) { return params.width; }/*w w w . j av a2 s . c om*/ view.measure(0, 0); width = view.getMeasuredWidth(); } return width; } return 0; }
From source file:Main.java
public static int getViewHeight(View view) { if (view != null) { int height = view.getMeasuredHeight(); if (height == 0) { LayoutParams params = view.getLayoutParams(); if (params != null && params.height > 0) { return params.height; }//from w ww . j av a 2 s .c o m view.measure(0, 0); height = view.getMeasuredHeight(); } return height; } return 0; }
From source file:Main.java
public static void animExpand(final View v) { v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); final int targetHeight = v.getMeasuredHeight(); v.getLayoutParams().height = 0; v.setVisibility(View.VISIBLE); Animation a = new Animation() { @Override//from w ww . j a va 2 s .c o m protected void applyTransformation(float interpolatedTime, Transformation t) { v.getLayoutParams().height = interpolatedTime == 1 ? LayoutParams.WRAP_CONTENT : (int) (targetHeight * interpolatedTime); v.requestLayout(); } @Override public boolean willChangeBounds() { return true; } }; // 1dp/ms a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density)); v.startAnimation(a); }
From source file:Main.java
public static void expand(final View v) { v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); final int targtetHeight = v.getMeasuredHeight(); v.getLayoutParams().height = 0; v.setVisibility(View.VISIBLE); Animation a = new Animation() { @Override//from ww w .j a v a2 s.c o m protected void applyTransformation(float interpolatedTime, Transformation t) { v.getLayoutParams().height = interpolatedTime == 1 ? LayoutParams.WRAP_CONTENT : (int) (targtetHeight * interpolatedTime); v.requestLayout(); } @Override public boolean willChangeBounds() { return true; } }; // 1dp/ms a.setDuration((int) (targtetHeight / v.getContext().getResources().getDisplayMetrics().density)); v.startAnimation(a); }
From source file:Main.java
public static void expand(final View v) { v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); final int targtetHeight = v.getMeasuredHeight(); v.getLayoutParams().height = 0; v.setVisibility(View.VISIBLE); Animation a = new Animation() { @Override/*w w w . ja v a 2 s .c o m*/ protected void applyTransformation(float interpolatedTime, Transformation t) { v.getLayoutParams().height = interpolatedTime == 1 ? LayoutParams.WRAP_CONTENT : (int) (targtetHeight * interpolatedTime); v.requestLayout(); } @Override public boolean willChangeBounds() { return true; } }; a.setDuration(300); v.startAnimation(a); }
From source file:Main.java
public static void expand(final View v) { v.measure(ViewGroup.LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); final int targtetHeight = v.getMeasuredHeight(); v.getLayoutParams().height = 0; v.setVisibility(View.VISIBLE); Animation a = new Animation() { @Override//ww w . j a va 2 s .c o m protected void applyTransformation(float interpolatedTime, Transformation t) { v.getLayoutParams().height = interpolatedTime == 1 ? LayoutParams.WRAP_CONTENT : (int) (targtetHeight * interpolatedTime); v.requestLayout(); } @Override public boolean willChangeBounds() { return true; } }; // 1dp/ms a.setDuration(1000); // a.setDuration((int)(targtetHeight / // v.getContext().getResources().getDisplayMetrics().density)); v.startAnimation(a); }
From source file:Main.java
public static void expand(final View v) { v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); final int targetHeight = v.getMeasuredHeight(); v.getLayoutParams().height = 0; v.setVisibility(View.VISIBLE); Animation a = new Animation() { @Override//from w ww.j av a 2 s .c om protected void applyTransformation(float interpolatedTime, Transformation t) { v.getLayoutParams().height = interpolatedTime == 1 ? ViewGroup.LayoutParams.WRAP_CONTENT : (int) (targetHeight * interpolatedTime); v.requestLayout(); } @Override public boolean willChangeBounds() { return true; } }; // 1dp/ms a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density)); v.startAnimation(a); }
From source file:Main.java
public static void expand(final View v) { v.measure(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); final int targetHeight = v.getMeasuredHeight(); v.getLayoutParams().height = 1; v.setVisibility(View.VISIBLE); Animation a = new Animation() { @Override/*from w ww. j av a2 s . co m*/ protected void applyTransformation(float interpolatedTime, Transformation t) { v.getLayoutParams().height = interpolatedTime == 1 ? RelativeLayout.LayoutParams.WRAP_CONTENT : (int) (targetHeight * interpolatedTime); v.requestLayout(); } @Override public boolean willChangeBounds() { return true; } }; a.setDuration(ANIM); v.startAnimation(a); }