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


Java ViewDragHelper.create方法代码示例

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


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

示例1: SwipeBackLayout

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
/**
 * \
 * 通过xml布局 自定义属性调用
 *
 * @param context 上下文
 * @param attrs   xml属性
 */
public SwipeBackLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    //①获取ViewDragHelper的实例
    mViewDragHelper = ViewDragHelper.create(this, 1.0f, new ViewDragHelperCallback());
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SwipeBackLayout);
    mDragDirectionMask = ta.getInt(R.styleable.SwipeBackLayout_dragDirection, NONE);
    mShadowColor = ta.getColor(R.styleable.SwipeBackLayout_shadowColor, mShadowColor);
    int contentLayoutId = ta.getResourceId(R.styleable.SwipeBackLayout_contentView,View.NO_ID);
    ta.recycle();

    addShadowView(context);
    if (View.NO_ID != contentLayoutId){
        mContentView = LayoutInflater.from(context).inflate(contentLayoutId, this, false);
        addView(mContentView);
    }
    enableSwipeBack = true;
}
 
开发者ID:zhouphenix,项目名称:Multi-SwipeBackLayout,代码行数:25,代码来源:SwipeBackLayout.java

示例2: DraggableSquareView

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
public DraggableSquareView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mDragHelper = ViewDragHelper
            .create(this, 10f, new DragHelperCallback());
    moveDetector = new GestureDetectorCompat(context,
            new MoveDetector());
    moveDetector.setIsLongpressEnabled(false); // 不能处理长按事件,否则违背最初设计的初衷
    spaceInterval = (int) getResources().getDimension(R.dimen.drag_square_interval); // 小方块之间的间隔

    // 滑动的距离阈值由系统提供
    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();

    anchorHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (draggingView != null) {
                // 开始移动重心的动画
                draggingView.startAnchorAnimation();
            }
        }
    };
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:24,代码来源:DraggableSquareView.java

示例3: QuickAttachmentDrawer

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
public QuickAttachmentDrawer(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);
  dragHelper = ViewDragHelper.create(this, 1.f, new ViewDragHelperCallback());
  initializeView();
  updateHalfExpandedAnchorPoint();
  onConfigurationChanged();
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:8,代码来源:QuickAttachmentDrawer.java

示例4: SlidingRootNavLayout

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
public SlidingRootNavLayout(Context context) {
    super(context);
    dragListeners = new ArrayList<>();
    dragStateListeners = new ArrayList<>();

    FLING_MIN_VELOCITY = ViewConfiguration.get(context).getScaledMinimumFlingVelocity();

    dragHelper = ViewDragHelper.create(this, new ViewDragCallback());

    dragProgress = 0f;
    isMenuHidden = true;
}
 
开发者ID:yarolegovich,项目名称:SlidingRootNav,代码行数:13,代码来源:SlidingRootNavLayout.java

示例5: DragLayout

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
public DragLayout(Context context, AttributeSet attrs, int defStyleAttr) {
                super(context, attrs, defStyleAttr);
                mGestureDetector = new GestureDetector(context, new 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);

                        }
                });
//                永远要记得,该工具实现的拖拉是基于控件位置的改变来实现的
                mViewDragHelper = ViewDragHelper.create(this, new DragViewCallBack());
        }
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:14,代码来源:DragLayout.java

示例6: TumblrRelativeLayout

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
public TumblrRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    marginBottom = (int) getResources().getDimension(R.dimen.float_marginBottom);
    marginRight = (int) getResources().getDimension(R.dimen.float_marginRight);

    mDragHelper = ViewDragHelper
            .create(this, 10f, new DragHelperCallback());
    mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_BOTTOM);
    gestureDetector = new GestureDetectorCompat(context,
            new MoveDetector());

    viewTrackController = ViewTrackController.create();
}
 
开发者ID:zongkaili,项目名称:MenuSet,代码行数:14,代码来源:TumblrRelativeLayout.java

示例7: onLayoutChild

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
@Override
public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) {
  if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) {
    ViewCompat.setFitsSystemWindows(child, true);
  }
  int savedTop = child.getTop();
  // First let the parent lay it out
  parent.onLayoutChild(child, layoutDirection);
  // Offset the bottom sheet
  mParentHeight = parent.getHeight();
  int peekHeight;
  if (mPeekHeightAuto) {
    if (mPeekHeightMin == 0) {
              mPeekHeightMin = parent.getResources().getDimensionPixelSize(
                      R.dimen.design_bottom_sheet_peek_height_min);
    }
    peekHeight = Math.max(mPeekHeightMin, mParentHeight - parent.getWidth() * 9 / 16);
  } else {
    peekHeight = mPeekHeight;
  }
  mMinOffset = Math.max(0, mParentHeight - child.getHeight());
  mMaxOffset = Math.max(mParentHeight - peekHeight, mMinOffset);
  if (mState == STATE_EXPANDED) {
    ViewCompat.offsetTopAndBottom(child, mMinOffset);
  } else if (mHideable && mState == STATE_HIDDEN) {
    ViewCompat.offsetTopAndBottom(child, mParentHeight);
  } else if (mState == STATE_COLLAPSED) {
    ViewCompat.offsetTopAndBottom(child, mMaxOffset);
  } else if (mState == STATE_DRAGGING || mState == STATE_SETTLING) {
    ViewCompat.offsetTopAndBottom(child, savedTop - child.getTop());
  }
  if (mViewDragHelper == null) {
    mViewDragHelper = ViewDragHelper.create(parent, mDragCallback);
  }
  mViewRef = new WeakReference<>(child);
  mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child));
  return true;
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:39,代码来源:BottomSheetBehavior.java

示例8: OverScrollLayout

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
public OverScrollLayout(@NonNull Context context, @NonNull View contentView, int directionMask) {
    super(context);
    mViewDragHelper = ViewDragHelper.create(this, 1.0f, new ViewDragHelperCallback());
    mContentView = contentView;
    mDirectionMask = directionMask;
    enableSwipe = true;
}
 
开发者ID:zhouphenix,项目名称:Multi-SwipeToRefreshLayout,代码行数:8,代码来源:OverScrollLayout.java

示例9: onLayoutChild

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
@Override
public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) {
    // First let the parent lay it out
    if (mState != STATE_DRAGGING && mState != STATE_SETTLING) {
        if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) {
            ViewCompat.setFitsSystemWindows(child, true);
        }
        parent.onLayoutChild(child, layoutDirection);
    }
    // Offset the bottom sheet
    mParentHeight = parent.getHeight();
    mMinOffset = Math.max(0, mParentHeight - child.getHeight());
    mMaxOffset = Math.max(mParentHeight - mPeekHeight, mMinOffset);
    mAnchorOffset = (int) Math.max(mParentHeight * mAnchorThreshold, mMinOffset);
    if (mState == STATE_EXPANDED) {
        ViewCompat.offsetTopAndBottom(child, mMinOffset);
    } else if (mState == STATE_ANCHOR) {
        ViewCompat.offsetTopAndBottom(child, mAnchorOffset);
    } else if (mHideable && mState == STATE_HIDDEN) {
        ViewCompat.offsetTopAndBottom(child, mParentHeight);
    } else if (mState == STATE_COLLAPSED) {
        ViewCompat.offsetTopAndBottom(child, mMaxOffset);
    }
    if (mViewDragHelper == null) {
        mViewDragHelper = ViewDragHelper.create(parent, mDragCallback);
    }
    mViewRef = new WeakReference<>(child);
    mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child));
    return true;
}
 
开发者ID:alphater,项目名称:garras,代码行数:31,代码来源:AnchorSheetBehavior.java

示例10: attachToRecyclerView

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
public void attachToRecyclerView(PhotoLooperView recyclerView) {
    this.mRecyclerView = recyclerView;
    mDragHelper = ViewDragHelper.create(recyclerView, 10f, new DragHelperCallback());
    initCenterViewX = recyclerView.getLeft();
    initCenterViewY = recyclerView.getTop();
    recyclerView.addOnItemTouchListener(this);
    recyclerView.setDragHelper(mDragHelper);
}
 
开发者ID:UniqueKenzhang,项目名称:PhotoLooper,代码行数:9,代码来源:PhotoItemTouchListener.java

示例11: initViewDragHelper

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
/**
 * Initializes ViewDragHelper.
 */
private void initViewDragHelper() {
    dragHelper = ViewDragHelper.create(this, DRAG_SENSITIVITY,
            new DragHelperCallback(this, draggableContainer));
}
 
开发者ID:davidmigloz,项目名称:drag-to-close,代码行数:8,代码来源:DragToClose.java

示例12: onAttachedToWindow

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    mDragHelper = ViewDragHelper.create(this, 1.0F, new DragCallback());
}
 
开发者ID:Piasy,项目名称:VideoCRE,代码行数:7,代码来源:MediaLayout.java

示例13: init

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
/**
 * initialize
 */
private void init() {
    viewDragHelper = ViewDragHelper.create(this, callback);
}
 
开发者ID:sleticalboy,项目名称:CustomWeight,代码行数:7,代码来源:SwipeLayout.java

示例14: initProperty

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
private void initProperty() {
    mDragHelper = ViewDragHelper.create(this, mDragHelperCallback);
    mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    mGestureDetectorCompat = new GestureDetectorCompat(getContext(), mSimpleOnGestureListener);
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:6,代码来源:SwipeItemLayout.java

示例15: initializeViewDragHelper

import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
/**
 * Initialize the viewDragHelper.
 */
private void initializeViewDragHelper()
{
    viewDragHelper = ViewDragHelper.create(this, SENSITIVITY, new DraggableViewCallback(this, dragView));
}
 
开发者ID:jbmlaird,项目名称:DiscogsBrowser,代码行数:8,代码来源:DraggableView.java


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