当前位置: 首页>>代码示例>>Java>>正文


Java View.addOnLayoutChangeListener方法代码示例

本文整理汇总了Java中android.view.View.addOnLayoutChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java View.addOnLayoutChangeListener方法的具体用法?Java View.addOnLayoutChangeListener怎么用?Java View.addOnLayoutChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.addOnLayoutChangeListener方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onLayout

import android.view.View; //导入方法依赖的package包/类
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;
}
 
开发者ID:roshakorost,项目名称:Phial,代码行数:20,代码来源:LayoutHelper.java

示例2: leftToRight

import android.view.View; //导入方法依赖的package包/类
/**
 * Анимация плавного перемещения 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);

        }
    });
}
 
开发者ID:interactiveservices,项目名称:utils-android,代码行数:30,代码来源:AnimUtils.java

示例3: addViewWithSubviewClippingEnabled

import android.view.View; //导入方法依赖的package包/类
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);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:17,代码来源:ReactViewGroup.java

示例4: setPopView

import android.view.View; //导入方法依赖的package包/类
/**
 * 设置要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;
}
 
开发者ID:zj565061763,项目名称:poper,代码行数:27,代码来源:FPoper.java

示例5: scrollToPosition

import android.view.View; //导入方法依赖的package包/类
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);
}
 
开发者ID:godness84,项目名称:react-native-recyclerview-list,代码行数:35,代码来源:RecyclerViewBackedScrollView.java

示例6: onCreateView

import android.view.View; //导入方法依赖的package包/类
@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;
}
 
开发者ID:woxingxiao,项目名称:GracefulMovies,代码行数:34,代码来源:SideFragment.java

示例7: onFinishInflate

import android.view.View; //导入方法依赖的package包/类
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    View view = getView();
    view.addOnLayoutChangeListener(this);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:8,代码来源:OverlayPanelTextViewInflater.java

示例8: circularReveal

import android.view.View; //导入方法依赖的package包/类
/**
 * Анимация "кругового" появления 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);
            }
        });
    }
}
 
开发者ID:interactiveservices,项目名称:utils-android,代码行数:48,代码来源:AnimUtils.java

示例9: setRemoveClippedSubviews

import android.view.View; //导入方法依赖的package包/类
@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;
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:36,代码来源:ReactViewGroup.java

示例10: onViewAdded

import android.view.View; //导入方法依赖的package包/类
@Override
public void onViewAdded(View child) {
    super.onViewAdded(child);
    child.addOnLayoutChangeListener(mChildLayoutChangeListener);
}
 
开发者ID:godness84,项目名称:react-native-recyclerview-list,代码行数:6,代码来源:RecyclerViewBackedScrollView.java

示例11: intPreScroll

import android.view.View; //导入方法依赖的package包/类
public static void intPreScroll(final SmoothAppBarLayout smoothAppBarLayout, final View target, final int offset) {
  target.addOnLayoutChangeListener(new OnPreScrollListener(smoothAppBarLayout, target, offset));
}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:4,代码来源:Utils.java

示例12: setListener

import android.view.View; //导入方法依赖的package包/类
/**
 *
 * @param bottomChangeView 一个在软件盘弹出是bottom会发生改变的View,如:被软件键盘向上顶的View,布局的根View。如果没有监听到,说明该View的bottom值没有随软键盘的弹出而改变
 * @param onKeyboardListener
 */
public static void setListener(View bottomChangeView, OnKeyboardListener onKeyboardListener) {
    bottomChangeView.addOnLayoutChangeListener(new KeyboardListener(bottomChangeView, onKeyboardListener));

}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:10,代码来源:KeyboardListener.java


注:本文中的android.view.View.addOnLayoutChangeListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。