當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。