本文整理汇总了Java中android.widget.Scroller.setFriction方法的典型用法代码示例。如果您正苦于以下问题:Java Scroller.setFriction方法的具体用法?Java Scroller.setFriction怎么用?Java Scroller.setFriction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Scroller
的用法示例。
在下文中一共展示了Scroller.setFriction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: QMUIPullRefreshLayout
import android.widget.Scroller; //导入方法依赖的package包/类
public QMUIPullRefreshLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setWillNotDraw(false);
final ViewConfiguration vc = ViewConfiguration.get(context);
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
mMiniVelocity = vc.getScaledMinimumFlingVelocity();
mSystemTouchSlop = vc.getScaledTouchSlop();
mTouchSlop = QMUIDisplayHelper.px2dp(context, mSystemTouchSlop); //系统的值是8dp,如何配置?
mScroller = new Scroller(getContext());
mScroller.setFriction(getScrollerFriction());
addRefreshView();
ViewCompat.setChildrenDrawingOrderEnabled(this, true);
mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);
TypedArray array = context.obtainStyledAttributes(attrs,
R.styleable.QMUIPullRefreshLayout, defStyleAttr, 0);
try {
mRefreshInitOffset = array.getDimensionPixelSize(
R.styleable.QMUIPullRefreshLayout_qmui_refresh_init_offset, Integer.MIN_VALUE);
mRefreshEndOffset = array.getDimensionPixelSize(
R.styleable.QMUIPullRefreshLayout_qmui_refresh_end_offset, Integer.MIN_VALUE);
mTargetInitOffset = array.getDimensionPixelSize(
R.styleable.QMUIPullRefreshLayout_qmui_target_init_offset, 0);
mTargetRefreshOffset = array.getDimensionPixelSize(
R.styleable.QMUIPullRefreshLayout_qmui_target_refresh_offset,
QMUIDisplayHelper.dp2px(getContext(), 72));
mAutoCalculateRefreshInitOffset = mRefreshInitOffset == Integer.MIN_VALUE ||
array.getBoolean(R.styleable.QMUIPullRefreshLayout_qmui_auto_calculate_refresh_init_offset, false);
mAutoCalculateRefreshEndOffset = mRefreshEndOffset == Integer.MIN_VALUE ||
array.getBoolean(R.styleable.QMUIPullRefreshLayout_qmui_auto_calculate_refresh_end_offset, false);
mEqualTargetRefreshOffsetToRefreshViewHeight = array.getBoolean(R.styleable.QMUIPullRefreshLayout_qmui_equal_target_refresh_offset_to_refresh_view_height, false);
} finally {
array.recycle();
}
mRefreshCurrentOffset = mRefreshInitOffset;
mTargetCurrentOffset = mTargetInitOffset;
}
示例2: setFriction
import android.widget.Scroller; //导入方法依赖的package包/类
/** Sets the friction for the provided scroller */
public static void setFriction(Scroller scroller, float friction) {
if (scroller != null) {
scroller.setFriction(friction);
}
}