Example usage for android.view View requestLayout

List of usage examples for android.view View requestLayout

Introduction

In this page you can find the example usage for android.view View requestLayout.

Prototype

@CallSuper
public void requestLayout() 

Source Link

Document

Call this when something has changed which has invalidated the layout of this view.

Usage

From source file:Main.java

static void setViewWidth(View view, int width) {
    view.getLayoutParams().width = width;
    view.requestLayout();
}

From source file:Main.java

/**
 * Sets the background image for a view.
 *///from   w  ww. j  av a2  s.c o m
public static void setBackgroundImage(View view, Drawable drawable) {
    view.setBackgroundDrawable(drawable);
    view.requestLayout();
}

From source file:Main.java

public static void setSize(@NonNull View view, int width, int height) {
    ViewGroup.LayoutParams lp = view.getLayoutParams();
    lp.height = height;/*from w w  w  .  j  a v  a 2s.c  o m*/
    lp.width = width;
    view.requestLayout();
}

From source file:Main.java

public static void resetMoveToZero(View viewToMove) {
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) viewToMove.getLayoutParams();
    params.topMargin = 0;//from   ww w  . j  ava 2  s .  c om
    viewToMove.setLayoutParams(params);
    viewToMove.requestLayout();
}

From source file:Main.java

public static void setViewLayoutParams(View view, int width, int height) {
    ViewGroup.LayoutParams params = view.getLayoutParams();
    params.width = width;//from w  w w . ja v a 2s .  c  om
    params.height = height;
    view.setLayoutParams(params);
    view.requestLayout();
}

From source file:Main.java

private static void setViewSize(View view, int size) {
    FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) view.getLayoutParams();
    params.width = size;//  w  w w .  j av  a  2 s. co m
    params.height = size;
    view.setLayoutParams(params);
    view.requestLayout();
}

From source file:Main.java

public static void setMargins(View v, int l, int t, int r, int b) {
    if (v.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
        p.setMargins(l, t, r, b);//w w w .  j  a v a2  s .  co m
        v.requestLayout();
    }
}

From source file:Main.java

public static void collapse(final View v, final int beHeight) {
    Animation a = new Animation() {
        @Override/*from  ww  w. j  a  v  a  2 s .c o  m*/
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = beHeight;
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration(500);
    v.startAnimation(a);
}

From source file:Main.java

public static void setMargins(View view, int left, int top, int right, int bottom) {
    if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        p.setMargins(left, top, right, bottom);
        view.requestLayout();
    }/*from  w  ww.  j a  v a2s  . c o  m*/
}

From source file:com.ruesga.rview.misc.BindingAdapters.java

@BindingAdapter("wrapLayoutWidth")
public static void wrapLayoutWidth(View v, boolean wrap) {
    v.getLayoutParams().width = wrap ? ViewGroup.LayoutParams.MATCH_PARENT
            : ViewGroup.LayoutParams.WRAP_CONTENT;
    v.requestLayout();
}