int measuredHeight = mContainer.getMeasuredHeight(); measuredWidth = mContainer.getMeasuredHeight();
public void onto(final ViewGroup target) { factor.width = target.getMeasuredWidth(); factor.height = target.getMeasuredHeight(); if (async) { BlurTask task = new BlurTask(target, factor, new BlurTask.Callback() { @Override public void done(BitmapDrawable drawable) { addView(target, drawable); if (listener != null) { listener.onImageReady(drawable); } } }); task.execute(); } else { Drawable drawable = new BitmapDrawable(context.getResources(), Blur.of(target, factor)); addView(target, drawable); } }
private static void createCircle(Context context, ViewGroup rootView, SpringSystem springSystem, SpringConfig coasting, SpringConfig gravity, int diameter, Drawable backgroundDrawable) { final Spring xSpring = springSystem.createSpring().setSpringConfig(coasting); final Spring ySpring = springSystem.createSpring().setSpringConfig(gravity); // create view View view = new View(context); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(diameter, diameter); params.addRule(RelativeLayout.CENTER_IN_PARENT); view.setLayoutParams(params); view.setBackgroundDrawable(backgroundDrawable); rootView.addView(view); // generate random direction and magnitude double magnitude = Math.random() * 1000 + 3000; double angle = Math.random() * Math.PI / 2 + Math.PI / 4; xSpring.setVelocity(magnitude * Math.cos(angle)); ySpring.setVelocity(-magnitude * Math.sin(angle)); int maxX = rootView.getMeasuredWidth() / 2 + diameter; xSpring.addListener(new Destroyer(rootView, view, -maxX, maxX)); int maxY = rootView.getMeasuredHeight() / 2 + diameter; ySpring.addListener(new Destroyer(rootView, view, -maxY, maxY)); xSpring.addListener(new Performer(view, View.TRANSLATION_X)); ySpring.addListener(new Performer(view, View.TRANSLATION_Y)); // set a different end value to cause the animation to play xSpring.setEndValue(2); ySpring.setEndValue(9001); }
private boolean isScrollable(ViewGroup listView) { int totalHeight = 0; for (int i = 0; i < listView.getChildCount(); i++) { totalHeight += listView.getChildAt(i).getMeasuredHeight(); } return listView.getMeasuredHeight() < totalHeight; }
public static void startBottomInAnim(final View target, long duration) { float y = ((ViewGroup) target.getParent()).getMeasuredHeight() - target.getTop(); ObjectAnimator translationY = ObjectAnimator.ofFloat(target, "translationY", y, 0); translationY.setInterpolator(new DecelerateInterpolator()); translationY.setDuration(duration); translationY.start(); }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); if (mHeaderContainer != null && mHeaderContainerHeight <= 0) { mHeaderContainerHeight = mHeaderContainer.getMeasuredHeight(); } if (mZoomView != null && mZoomViewHeight <= 0) { mZoomViewHeight = mZoomView.getMeasuredHeight(); } }
private static int calculateContainerHeight() { int mHeightOverride = XposedHelpers.getIntField(mQSContainer, "mHeightOverride"); int heightOverride = mHeightOverride != -1 ? mHeightOverride : mQSContainer.getMeasuredHeight() - mHeaderHeight; return (int) (mQsExpansion * heightOverride) + mHeaderHeight; }
@Override @NonNull protected Animator getAnimator(@NonNull final ViewGroup parent, @NonNull final View view) { return ObjectAnimator.ofFloat(view, TRANSLATION_Y, parent.getMeasuredHeight() >> 1, 0); }
public static void startBottomOutAnim(final View target, long duration) { float y = ((ViewGroup) target.getParent()).getMeasuredHeight() - target.getTop(); ObjectAnimator translationY = ObjectAnimator.ofFloat(target, "translationY", target.getTranslationY(), y); translationY.setInterpolator(new DecelerateInterpolator()); translationY.setDuration(duration); translationY.start(); }
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = mLayoutInflater.inflate(R.layout.view_item, parent, false); // work here if you need to control height of your items // keep in mind that parent is RecyclerView in this case int height = parent.getMeasuredHeight() / 4; itemView.setMinimumHeight(height); return new ItemViewHolder(itemView); }
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater .from(parent.getContext()) .inflate(R.layout.item_list, null); int height = parent.getMeasuredHeight() / 4; int width = parent.getMeasuredWidth(); view.setLayoutParams(new RecyclerView.LayoutParams(width, height)); return new ViewHolder(view); }
public static int stringToDimensionPixelSize(String dimension, DisplayMetrics metrics, ViewGroup parent, boolean horizontal) { if (dimension.endsWith("%")) { float pct = Float.parseFloat(dimension.substring(0, dimension.length() - 1)) / 100.0f; return (int)(pct * (horizontal ? parent.getMeasuredWidth() : parent.getMeasuredHeight())); } return stringToDimensionPixelSize(dimension, metrics); } public static int stringToDimensionPixelSize(String dimension, DisplayMetrics metrics) {
@Override public void scrollAViewBy(int dp) { if (scrollView.getChildCount() != 0) { float maxScrollY = scrollView.getChildAt(0).getHeight() - scrollView.getMeasuredHeight(); if (scrollView.getScrollY() + dp >= maxScrollY) { scrollView.scrollTo(0, (int) maxScrollY); } else { scrollView.scrollBy(0, dp); } } } }
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { viewWidth = getWidth(); dismissOffsetThreshold = viewWidth / 3; if (layoutGravity == Gravity.TOP) { super.onLayout(changed, l, 0, r, layoutCookie.getMeasuredHeight()); } else { super.onLayout(changed, l, t, r, b); } }
@Override public void run() { LogUtils.i(String.format("width=%s, height=%s, measureWidth=%s, measureHeight=%s", mCaptureView.getWidth(), mCaptureView.getHeight(), mCaptureView.getMeasuredWidth(), mCaptureView.getMeasuredHeight())); } });
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); mWidth = mContentLayout.getMeasuredWidth(); mHeight = mContentLayout.getMeasuredHeight(); mSwipeWidth = mBehindLayout.getMeasuredWidth(); }
@Override public void run() { LogUtils.i(String.format("width=%s, height=%s, measureWidth=%s, measureHeight=%s", mCaptureView.getWidth(), mCaptureView.getHeight(), mCaptureView.getMeasuredWidth(), mCaptureView.getMeasuredHeight())); } });
public int getDesiredHeight() { if (mQSDetail.isClosingDetail()) { return (int) XposedHelpers.callMethod(mQSPanel, "getGridHeight") + mQsTopMargin + mQSContainer.getPaddingBottom(); } else { return mQSContainer.getMeasuredHeight(); } }
private int getParentScrollDistance () { int distance =0; if(mScrolledParent==null) { return distance; } distance = (int) (getY()+getMeasuredHeight()+mExpandedViewHeight -mScrolledParent.scrolledView.getMeasuredHeight()); for(int index =0;index<mScrolledParent.childBetweenParentCount;index++) { ViewGroup parent = (ViewGroup) getParent(); distance+=parent.getY(); } return distance; }
ViewGroup v1 = (ViewGroup) activity.findViewById(id).getRootView(); v1.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); v1.layout(0, 0, v1.getMeasuredWidth(), v1.getMeasuredHeight()); v1.buildDrawingCache(true); Bitmap source = Bitmap.createBitmap(v1.getDrawingCache()); v1.setDrawingCacheEnabled(false); // clear drawing cache