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:com.gdgdevfest.android.apps.devfestbcn.ui.tablet.MapMultiPaneActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    boolean landscape = (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE);

    LinearLayout spacerView = (LinearLayout) findViewById(R.id.map_detail_spacer);
    spacerView.setOrientation(landscape ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
    spacerView.setGravity(landscape ? Gravity.END : Gravity.BOTTOM);

    View popupView = findViewById(R.id.map_detail_popup);
    LinearLayout.LayoutParams popupLayoutParams = (LinearLayout.LayoutParams) popupView.getLayoutParams();
    popupLayoutParams.width = landscape ? 0 : ViewGroup.LayoutParams.MATCH_PARENT;
    popupLayoutParams.height = landscape ? ViewGroup.LayoutParams.MATCH_PARENT : 0;
    popupView.setLayoutParams(popupLayoutParams);

    popupView.requestLayout();

    updateMapPadding();/*w w w  .  ja  v  a2 s .  c  o m*/
}

From source file:com.hacktx.android.activities.CheckInActivity.java

private void setupStatusBar() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        setTranslucentStatusFlag(true);/*from   w  ww.j a v a2s. c o  m*/
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setTranslucentStatusFlag(false);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final View scrollView = findViewById(R.id.scrollView);
        final int bigMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24,
                getResources().getDisplayMetrics());

        ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) scrollView.getLayoutParams();
        p.setMargins(0, bigMargin, 0, 0);
        scrollView.requestLayout();
    }
}

From source file:com.android.contacts.list.MultiSelectContactsListFragment.java

private void setMargins(View v, int l, int r) {
    if (v.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
        p.setMarginStart(l);// w w w .  j  av  a  2s .c  o  m
        p.setMarginEnd(r);
        v.setLayoutParams(p);
        v.requestLayout();
    }
}

From source file:com.ruesga.rview.wizard.WizardActivity.java

private Animator createHeaderAnimation(int from, int to) {
    final ValueAnimator animator = ValueAnimator.ofInt(from, to);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(250L);/*w  ww.ja  v a2  s  .c  o  m*/
    animator.addUpdateListener(animation -> {
        final View v = mBinding.pageHeader;
        v.getLayoutParams().height = (Integer) animation.getAnimatedValue();
        v.requestLayout();
    });
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animator) {
            mWorkflow.isBackEnabled = false;
            mWorkflow.isForwardEnabled = false;
            mBinding.setWorkflow(mWorkflow);
            mIsHeaderAnimatorRunning = true;
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            if (mCurrentPageFragment != null) {
                onValidationChanged(mCurrentPageFragment);
            }
            mBinding.setWorkflow(mWorkflow);
            mIsHeaderAnimatorRunning = false;
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    return animator;
}

From source file:com.veniosg.dir.android.activity.FileManagerActivity.java

/**
 * Calculating width based on/*  w w w .  j a  v a2 s.c  om*/
 * http://www.google.com/design/spec/patterns/navigation-drawer.html#navigation-drawer-specs.
 */
private void setOptimalDrawerWidth(View drawerContainer) {
    int actionBarSize = 0;
    TypedValue tv = new TypedValue();
    if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        actionBarSize = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
    }

    ViewGroup.LayoutParams params = drawerContainer.getLayoutParams();
    DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
    int minScreenWidth = min(displayMetrics.widthPixels, displayMetrics.heightPixels);

    params.width = min(minScreenWidth - actionBarSize, 5 * actionBarSize);
    drawerContainer.requestLayout();
}

From source file:com.github.shareme.gwsmaterialuikit.library.viewanimator.AnimationBuilder.java

/**
 * Width animation builder./*from   w  w  w .  ja v  a  2  s .  c o m*/
 *
 * @param width the width
 * @return the animation builder
 */
public AnimationBuilder width(float... width) {
    return custom(new AnimationListener.Update() {
        @Override
        public void update(View view, float value) {
            view.getLayoutParams().width = (int) value;
            view.requestLayout();
        }
    }, width);
}

From source file:com.github.shareme.gwsmaterialuikit.library.viewanimator.AnimationBuilder.java

/**
 * Height animation builder./*from  www .ja  va2  s  . c  om*/
 *
 * @param height the height
 * @return the animation builder
 */
public AnimationBuilder height(float... height) {
    return custom(new AnimationListener.Update() {
        @Override
        public void update(View view, float value) {
            view.getLayoutParams().height = (int) value;
            view.requestLayout();
        }
    }, height);
}

From source file:com.example.android.expandingcells.ExpandingListView.java

/**
 * Sets the top and bottom of the view//from ww  w.  j  a va 2s. c o m
 * @param v
 * @param top
 * @param bottom
 */
private void handleSetTopAndBottom(View v, int top, int bottom) {
    ViewGroup.LayoutParams p = this.getLayoutParams();
    if (p instanceof AbsListView.LayoutParams) {
        AbsListView.LayoutParams lp = (AbsListView.LayoutParams) p;
        lp.height = bottom - top;
        this.setLayoutParams(lp);
        v.requestLayout();
    }
}

From source file:com.fastbootmobile.encore.utils.Utils.java

/**
 * Animate a view expansion (unwrapping)
 *
 * @param v      The view to animate//from   ww w  .  ja va  2s. c  o  m
 * @param expand True to animate expanding, false to animate closing
 * @return The animation object created
 */
public static Animation animateExpand(final View v, final boolean expand) {
    try {
        Method m = v.getClass().getDeclaredMethod("onMeasure", int.class, int.class);
        m.setAccessible(true);
        m.invoke(v, View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec
                .makeMeasureSpec(((View) v.getParent()).getMeasuredWidth(), View.MeasureSpec.UNSPECIFIED));
    } catch (Exception e) {
        e.printStackTrace();
    }

    final int initialHeight = v.getMeasuredHeight();

    if (expand) {
        v.getLayoutParams().height = 0;
    } else {
        v.getLayoutParams().height = initialHeight;
    }
    v.setVisibility(View.VISIBLE);

    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            int newHeight;
            if (expand) {
                newHeight = (int) (initialHeight * interpolatedTime);
            } else {
                newHeight = (int) (initialHeight * (1 - interpolatedTime));
            }
            v.getLayoutParams().height = newHeight;
            v.requestLayout();

            if (interpolatedTime == 1 && !expand)
                v.setVisibility(View.GONE);
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };
    a.setDuration(500);
    return a;
}

From source file:com.github.omadahealth.slidepager.lib.views.ProgressView.java

/**
 * Allows to set the {@link ViewProgressBinding#progressStreakLeft} or {@link ViewProgressBinding#progressStreakRight} height accordingly to the CircularBar dimension.
 *
 * @param streakHeight The streak we want to set the dimension to
 *///from  ww  w . j  av a  2  s . c o  m
public void setStreakHeight(View streakHeight) {
    streakHeight.getLayoutParams().height = (int) mBinding.circularBar.getDiameter();
    streakHeight.requestLayout();
}