本文整理匯總了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));
}