android.view.View#requestLayout ( )源码实例Demo

下面列出了android.view.View#requestLayout ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: appinventor-extensions   文件: ViewUtil.java
public static void setChildHeightForHorizontalLayout(View view, int height) {
  // In a horizontal layout, if a child's height is set to fill parent, we can simply set the
  // LayoutParams height to fill parent.
  Object layoutParams = view.getLayoutParams();
  if (layoutParams instanceof LinearLayout.LayoutParams) {
    LinearLayout.LayoutParams linearLayoutParams = (LinearLayout.LayoutParams) layoutParams;
    switch (height) {
      case Component.LENGTH_PREFERRED:
        linearLayoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
        break;
      case Component.LENGTH_FILL_PARENT:
        linearLayoutParams.height = LinearLayout.LayoutParams.FILL_PARENT;
        break;
      default:
        linearLayoutParams.height = calculatePixels(view, height);
        break;
    }
    view.requestLayout();
  } else {
    Log.e("ViewUtil", "The view does not have linear layout parameters");
  }
}
 
源代码2 项目: Nimbus   文件: GalleryView.java
public void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

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

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

    // 1dp/ms
    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
 
源代码3 项目: imsdk-android   文件: AndroidTreeView.java
private static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

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

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

    // 1dp/ms
    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
 
源代码4 项目: MultiItem   文件: ViewScaleHelper.java
/**
 * 关闭缩放
 */
public synchronized void stopScaleModel() {
    if (!isInScaleMode) {
        return;
    }
    isInScaleMode = false;
    restoreView(contentView);
    restoreView(horizontalView);
    for (View view : verticalViewList) {
        restoreView(view);
        view.requestLayout();
    }
    horizontalView.setScaleX(1f);
    horizontalView.setScaleY(1f);

}
 
源代码5 项目: recyclerview-expandable   文件: ExpandableItem.java
@UiThread
private void collapse(@NonNull final View view) {
    isOpened = false;
    final int initialHeight = view.getMeasuredHeight();

    final Animation animation = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                view.setVisibility(View.GONE);
                isOpened = false;
            } else {
                view.getLayoutParams().height = initialHeight -
                    (int) (initialHeight * interpolatedTime);
                view.requestLayout();
            }
        }
    };
    animation.setDuration(duration);
    view.startAnimation(animation);
}
 
源代码6 项目: javaide   文件: AndroidTreeView.java
private static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

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

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

    // 1dp/ms
    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
 
源代码7 项目: commcare-android   文件: QuestionWidget.java
private static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

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

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

    // 1dp/ms
    a.setDuration((int)(initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
 
源代码8 项目: MVPAndroidBootstrap   文件: DownExpandAnimation.java
public static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

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

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

    // 1dp/ms
    a.setDuration(500);
    v.startAnimation(a);
}
 
源代码9 项目: bcm-android   文件: CollapseAnimator.java
public static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

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

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

    // 1dp/ms
    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
 
源代码10 项目: XPrivacy   文件: ActivityShare.java
private void blueStreakOfProgress(Integer current, Integer max) {
	// Set up the progress bar
	if (mProgressWidth == 0) {
		final View vShareProgressEmpty = (View) findViewById(R.id.vShareProgressEmpty);
		mProgressWidth = vShareProgressEmpty.getMeasuredWidth();
	}
	// Display stuff
	if (max == 0)
		max = 1;
	int width = (int) ((float) mProgressWidth) * current / max;

	View vShareProgressFull = (View) findViewById(R.id.vShareProgressFull);
	vShareProgressFull.getLayoutParams().width = width;
	vShareProgressFull.invalidate();
	vShareProgressFull.requestLayout();
}
 
源代码11 项目: MapViewPager   文件: Utils.java
public static void setMargins(View view, int left, int top, int right, int bottom) {
    if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        params.setMargins(left, top, right, bottom);
        view.requestLayout();
    }
}
 
源代码12 项目: 365browser   文件: ChromeFullscreenManager.java
private void applyMarginToFullChildViews(ViewGroup contentView, float margin) {
    for (int i = 0; i < contentView.getChildCount(); i++) {
        View child = contentView.getChildAt(i);
        if (!(child.getLayoutParams() instanceof FrameLayout.LayoutParams)) continue;
        FrameLayout.LayoutParams layoutParams =
                (FrameLayout.LayoutParams) child.getLayoutParams();

        if (layoutParams.height == LayoutParams.MATCH_PARENT
                && layoutParams.topMargin != (int) margin) {
            layoutParams.topMargin = (int) margin;
            child.requestLayout();
            TraceEvent.instant("FullscreenManager:child.requestLayout()");
        }
    }
}
 
源代码13 项目: OpenWeatherPlus-Android   文件: MainActivity.java
/**
 * 兼容全面屏的状态栏高度
 */
public void setMargins(View view, int l, int t, int r, int b) {
    if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        p.setMargins(l, t, r, b);
        view.requestLayout();
    }
}
 
源代码14 项目: UltimateAndroid   文件: StaggeredGridView.java
private void requestLayoutChildren() {
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View v = getChildAt(i);
        if (v != null) v.requestLayout();
    }
}
 
源代码15 项目: FocusResize   文件: FocusResizeScrollListener.java
private void calculateScrolledPosition(int totalItemCount, RecyclerView recyclerView) {
    for (int j = 0; j < totalItemCount - 1; j++) {
        View view = recyclerView.getChildAt(j);
        if (view != null) {
            if (!(recyclerView.getChildViewHolder(view) instanceof FocusResizeAdapter.FooterViewHolder)) {
                if (j == itemToResize) {
                    onItemBigResize(view, recyclerView);
                } else {
                    onItemSmallResize(view, recyclerView);
                }
                view.requestLayout();
            }
        }
    }
}
 
源代码16 项目: AcDisplay   文件: ViewUtils.java
public static void setSize(@NonNull View view, int width, int height) {
    ViewGroup.LayoutParams lp = view.getLayoutParams();
    lp.height = height;
    lp.width = width;
    view.requestLayout();
}
 
源代码17 项目: Phlux   文件: DemoActivity.java
private void setWeight(int id, float progress) {
    View before = findViewById(id);
    LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) before.getLayoutParams();
    layoutParams.weight = progress;
    before.requestLayout();
}
 
源代码18 项目: PicKing   文件: ScreenUtil.java
/**
 * 设置view margin
 *
 * @param v
 * @param l
 * @param t
 * @param r
 * @param b
 */
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);
        v.requestLayout();
    }
}
 
源代码19 项目: SUtil   文件: ViewUtils.java
/**
 * 设置View的外边距(Margins)
 *
 * @param view   要设置外边距的View
 * @param left   左侧外边距
 * @param top    顶部外边距
 * @param right  右侧外边距
 * @param bottom 底部外边距
 */
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();       //请求重绘
    }
}
 
源代码20 项目: SlidePager   文件: 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
 */
public void setStreakHeight(View streakHeight) {
    streakHeight.getLayoutParams().height = (int) mBinding.circularBar.getDiameter();
    streakHeight.requestLayout();
}
 
 方法所在类
 同类方法