Java Code Examples for android.view.View.addOnLayoutChangeListener()
The following are Jave code examples for showing how to use
addOnLayoutChangeListener() of the
android.view.View
class.
You can vote up the examples you like. Your votes will be used in our system to get
more good examples.
+ Save this method
Example 1
Project: Phial File: LayoutHelper.java View Source Code | 6 votes |
static Disposable onLayout(ViewsDidLayoutListener listener, View... views) { final Set<View> unmeasured = new HashSet<>(); for (View view : views) { if (!isViewMeasured(view)) { unmeasured.add(view); } } final MyLayoutListener layoutListener = new MyLayoutListener(listener, unmeasured); for (View target : unmeasured) { target.addOnLayoutChangeListener(layoutListener); } if (unmeasured.isEmpty()) { listener.onLayout(); } return layoutListener; }
Example 2
Project: utils-android File: AnimUtils.java View Source Code | 6 votes |
/** * Анимация плавного перемещения view слева направо * * @param context контекст * @param view перемещаемое view * @param duration длительность анимации в миллисекундах */ public static void leftToRight(final Context context, final View view, final long duration) { view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { v.removeOnLayoutChangeListener(this); Animation anim = android.view.animation.AnimationUtils.loadAnimation(context, R.anim.slide_in_left); anim.setDuration(duration); v.startAnimation(anim); } }); }
Example 3
Project: RNLearn_Project1 File: ReactViewGroup.java View Source Code | 6 votes |
void addViewWithSubviewClippingEnabled(View child, int index, LayoutParams params) { Assertions.assertCondition(mRemoveClippedSubviews); Assertions.assertNotNull(mClippingRect); Assertions.assertNotNull(mAllChildren); addInArray(child, index); // we add view as "clipped" and then run {@link #updateSubviewClipStatus} to conditionally // attach it int clippedSoFar = 0; for (int i = 0; i < index; i++) { if (mAllChildren[i].getParent() == null) { clippedSoFar++; } } updateSubviewClipStatus(mClippingRect, index, clippedSoFar); child.addOnLayoutChangeListener(mChildrenLayoutChangeListener); }
Example 4
Project: RNLearn_Project1 File: ReactViewGroup.java View Source Code | 6 votes |
void addViewWithSubviewClippingEnabled(View child, int index, LayoutParams params) { Assertions.assertCondition(mRemoveClippedSubviews); Assertions.assertNotNull(mClippingRect); Assertions.assertNotNull(mAllChildren); addInArray(child, index); // we add view as "clipped" and then run {@link #updateSubviewClipStatus} to conditionally // attach it int clippedSoFar = 0; for (int i = 0; i < index; i++) { if (mAllChildren[i].getParent() == null) { clippedSoFar++; } } updateSubviewClipStatus(mClippingRect, index, clippedSoFar); child.addOnLayoutChangeListener(mChildrenLayoutChangeListener); }
Example 5
Project: poper File: FPoper.java View Source Code | 6 votes |
/** * 设置要Pop的view * * @param popView * @return */ public FPoper setPopView(View popView) { final View old = mPopView; if (old != popView) { if (old != null) { old.removeOnLayoutChangeListener(mOnLayoutChangeListenerPopView); } mPopView = popView; if (popView != null) { popView.removeOnLayoutChangeListener(mOnLayoutChangeListenerPopView); popView.addOnLayoutChangeListener(mOnLayoutChangeListenerPopView); } } return this; }
Example 6
Project: react-native-recyclerview-list File: RecyclerViewBackedScrollView.java View Source Code | 5 votes |
public void scrollToPosition(final int position, final ScrollOptions options) { if (options.viewPosition != null) { final LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager(); final ReactListAdapter adapter = (ReactListAdapter) getAdapter(); final View view = adapter.getViewByItemIndex(position); if (view != null) { final int viewHeight = view.getHeight(); // In order to calculate the correct offset, we need the height of the target view. // If the height of the view is not available it means RN has not calculated it yet. // So let's listen to the layout change and we will retry scrolling. if (viewHeight == 0) { view.addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { view.removeOnLayoutChangeListener(this); scrollToPosition(position, options); } }); return; } final int boxStart = layoutManager.getPaddingTop(); final int boxEnd = layoutManager.getHeight() - layoutManager.getPaddingBottom(); final int boxHeight = boxEnd - boxStart; float viewOffset = options.viewOffset != null ? PixelUtil.toPixelFromDIP(options.viewOffset) : 0; int offset = (int) ((boxHeight - viewHeight) * options.viewPosition + viewOffset); layoutManager.scrollToPositionWithOffset(position, offset); return; } } super.scrollToPosition(position); }
Example 7
Project: GracefulMovies File: SideFragment.java View Source Code | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.cloneInContext(new ContextThemeWrapper(getContext(), getTheme())) .inflate(R.layout.fragment_side, container, false); final Bundle args = getArguments(); if (args != null) { rootView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { v.removeOnLayoutChangeListener(this); int cx = args.getInt("cx"); int cy = args.getInt("cy"); // get the hypotheses so the mRadius is from one corner to the other float radius = (float) Math.hypot(right, bottom); // Hardware-supported clipPath() // http://developer.android.com/guide/topics/graphics/hardware-accel.html if (Build.VERSION.SDK_INT >= 18) { isAnimRunning = true; Animator reveal = createCheckoutRevealAnimator((ClipRevealFrame) v, cx, cy, 28f, radius); reveal.start(); } else { removeOldSideFragment(); } } }); } ButterKnife.bind(this, rootView); return rootView; }
Example 8
Project: chromium-for-android-56-debug-video File: OverlayPanelTextViewInflater.java View Source Code | 5 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); View view = getView(); view.addOnLayoutChangeListener(this); }
Example 9
Project: utils-android File: AnimUtils.java View Source Code | 5 votes |
/** * Анимация "кругового" появления view * * @param context контекст * @param view появляемая view * @param revealSettings настройки анимации * @param startColor начальный цвет фона view * @param endColor конечный цвет фона view */ public static void circularReveal(final Context context, final View view, final RevealAnimationSetting revealSettings, final int startColor, final int endColor) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { v.removeOnLayoutChangeListener(this); int cx = revealSettings.getCenterX(); int cy = revealSettings.getCenterY(); int width = revealSettings.getWidth(); int height = revealSettings.getHeight(); int duration = context.getResources() .getInteger(android.R.integer.config_mediumAnimTime); //Simply use the diagonal of the view float finalRadius = (float) Math.sqrt(width * width + height * height); Animator anim = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, finalRadius) .setDuration(duration); anim.setInterpolator(new FastOutSlowInInterpolator()); anim.start(); recolorBackground(view, startColor, endColor, duration); } }); } }
Example 10
Project: RNLearn_Project1 File: ReactViewGroup.java View Source Code | 5 votes |
@Override public void setRemoveClippedSubviews(boolean removeClippedSubviews) { if (removeClippedSubviews == mRemoveClippedSubviews) { return; } mRemoveClippedSubviews = removeClippedSubviews; if (removeClippedSubviews) { mClippingRect = new Rect(); ReactClippingViewGroupHelper.calculateClippingRect(this, mClippingRect); mAllChildrenCount = getChildCount(); int initialSize = Math.max(12, mAllChildrenCount); mAllChildren = new View[initialSize]; mChildrenLayoutChangeListener = new ChildrenLayoutChangeListener(this); for (int i = 0; i < mAllChildrenCount; i++) { View child = getChildAt(i); mAllChildren[i] = child; child.addOnLayoutChangeListener(mChildrenLayoutChangeListener); } updateClippingRect(); } else { // Add all clipped views back, deallocate additional arrays, remove layoutChangeListener Assertions.assertNotNull(mClippingRect); Assertions.assertNotNull(mAllChildren); Assertions.assertNotNull(mChildrenLayoutChangeListener); for (int i = 0; i < mAllChildrenCount; i++) { mAllChildren[i].removeOnLayoutChangeListener(mChildrenLayoutChangeListener); } getDrawingRect(mClippingRect); updateClippingToRect(mClippingRect); mAllChildren = null; mClippingRect = null; mAllChildrenCount = 0; mChildrenLayoutChangeListener = null; } }
Example 11
Project: RNLearn_Project1 File: ReactViewGroup.java View Source Code | 5 votes |
@Override public void setRemoveClippedSubviews(boolean removeClippedSubviews) { if (removeClippedSubviews == mRemoveClippedSubviews) { return; } mRemoveClippedSubviews = removeClippedSubviews; if (removeClippedSubviews) { mClippingRect = new Rect(); ReactClippingViewGroupHelper.calculateClippingRect(this, mClippingRect); mAllChildrenCount = getChildCount(); int initialSize = Math.max(12, mAllChildrenCount); mAllChildren = new View[initialSize]; mChildrenLayoutChangeListener = new ChildrenLayoutChangeListener(this); for (int i = 0; i < mAllChildrenCount; i++) { View child = getChildAt(i); mAllChildren[i] = child; child.addOnLayoutChangeListener(mChildrenLayoutChangeListener); } updateClippingRect(); } else { // Add all clipped views back, deallocate additional arrays, remove layoutChangeListener Assertions.assertNotNull(mClippingRect); Assertions.assertNotNull(mAllChildren); Assertions.assertNotNull(mChildrenLayoutChangeListener); for (int i = 0; i < mAllChildrenCount; i++) { mAllChildren[i].removeOnLayoutChangeListener(mChildrenLayoutChangeListener); } getDrawingRect(mClippingRect); updateClippingToRect(mClippingRect); mAllChildren = null; mClippingRect = null; mAllChildrenCount = 0; mChildrenLayoutChangeListener = null; } }
Example 12
Project: react-native-recyclerview-list File: RecyclerViewBackedScrollView.java View Source Code | 4 votes |
@Override public void onViewAdded(View child) { super.onViewAdded(child); child.addOnLayoutChangeListener(mChildLayoutChangeListener); }
Example 13
Project: Expert-Android-Programming File: Utils.java View Source Code | 4 votes |
public static void intPreScroll(final SmoothAppBarLayout smoothAppBarLayout, final View target, final int offset) { target.addOnLayoutChangeListener(new OnPreScrollListener(smoothAppBarLayout, target, offset)); }
Example 14
Project: FriendBook File: KeyboardListener.java View Source Code | 2 votes |
/** * * @param bottomChangeView 一个在软件盘弹出是bottom会发生改变的View,如:被软件键盘向上顶的View,布局的根View。如果没有监听到,说明该View的bottom值没有随软键盘的弹出而改变 * @param onKeyboardListener */ public static void setListener(View bottomChangeView, OnKeyboardListener onKeyboardListener) { bottomChangeView.addOnLayoutChangeListener(new KeyboardListener(bottomChangeView, onKeyboardListener)); }