Java Code Examples for androidx.core.view.ViewCompat#setChildrenDrawingOrderEnabled()

The following examples show how to use androidx.core.view.ViewCompat#setChildrenDrawingOrderEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PullRefreshLayout.java    From QuickDevFramework with Apache License 2.0 6 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mDurationToStartPosition = getResources().getInteger(android.R.integer.config_longAnimTime);
    mDurationToCorrectPosition = getResources().getInteger(android.R.integer.config_longAnimTime);
    mSpinnerFinalOffset = mTotalDragDistance = dp2px(DEFAULT_MAX_DRAG_DISTANCE);
    
    mDecelerateInterpolator = new DecelerateInterpolator(2);
    
    setWillNotDraw(false);
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    
    setRefreshView(new DefaultRefreshView(context));
    
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);
    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
}
 
Example 2
Source File: CustomSwipeRefreshLayout.java    From NewFastFrame with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context
 * @param attrs
 */
public CustomSwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            //                                如果水平方向的偏移量大于竖直方向的偏移量,就消化该事件,
            return Math.abs(distanceX) > Math.abs(distanceY) || super.onScroll(e1, e2, distanceX, distanceY);

        }
    });
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(
            android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    if (((IAdaptScreen) getContext()).cancelAdapt()) {
        mCircleDiameter = (int) (MaterialProgressDrawable.CIRCLE_DIAMETER_LARGE * metrics.density);
    } else {
        mCircleDiameter = (int) (MaterialProgressDrawable.CIRCLE_DIAMETER * metrics.density);
    }

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerOffsetEnd = (int) (DEFAULT_CIRCLE_TARGET * metrics.density);
    mTotalDragDistance = mSpinnerOffsetEnd;
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);

    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);

    mOriginalOffsetTop = mCurrentTargetOffsetTop = -mCircleDiameter;
    moveToStart(1.0f);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();
}