本文整理汇总了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;
}
示例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();
}
}
};
}
示例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();
}
示例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;
}
示例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());
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例11: initViewDragHelper
import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
/**
* Initializes ViewDragHelper.
*/
private void initViewDragHelper() {
dragHelper = ViewDragHelper.create(this, DRAG_SENSITIVITY,
new DragHelperCallback(this, draggableContainer));
}
示例12: onAttachedToWindow
import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mDragHelper = ViewDragHelper.create(this, 1.0F, new DragCallback());
}
示例13: init
import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
/**
* initialize
*/
private void init() {
viewDragHelper = ViewDragHelper.create(this, callback);
}
示例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);
}
示例15: initializeViewDragHelper
import android.support.v4.widget.ViewDragHelper; //导入方法依赖的package包/类
/**
* Initialize the viewDragHelper.
*/
private void initializeViewDragHelper()
{
viewDragHelper = ViewDragHelper.create(this, SENSITIVITY, new DraggableViewCallback(this, dragView));
}