Ale*_*lex 7 android android-scroll android-number-picker
如何使数字选择器滚动/速度更快?目前从00分钟到59分钟需要付出很多努力.我已经尝试了一些示例来自Android中Viewpager控制器的减速速度,并将其应用于数字选择器,但我没有看到任何差异.
try {
Field mScroller;
mScroller = NumberPicker.class.getDeclaredField("mFlingScroller");
mScroller.setAccessible(true);
FixedSpeedScroller scroller = new FixedSpeedScroller(getContext(),null,true);
// scroller.setFixedDuration(5000);
// scrollBy(0,1500);
Log.v("Scroller",""+mScroller); //getting the mFlingScroller field
mScroller.set(this, scroller);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
public class FixedSpeedScroller extends Scroller {
private int mDuration = 10;
public FixedSpeedScroller(Context context) {
super(context);
}
public FixedSpeedScroller(Context context, Interpolator interpolator) {
super(context, interpolator);
}
public FixedSpeedScroller(Context context, Interpolator interpolator, boolean flywheel) {
super(context, interpolator, flywheel);
}
@Override
public void startScroll(int startX, int startY, int dx, int dy, int duration) {
// Ignore received duration, use fixed one instead
super.startScroll(startX, startY, dx, dy, mDuration);
}
@Override
public void startScroll(int startX, int startY, int dx, int dy) {
// Ignore received duration, use fixed one instead
super.startScroll(startX, startY, dx, dy, mDuration);
}
}
Run Code Online (Sandbox Code Playgroud)
我将mDuration减少到低于示例(5000)的值.但仍然没有希望.一些帮助将不胜感激.提前致谢!!!:)
| 归档时间: |
|
| 查看次数: |
915 次 |
| 最近记录: |