ViewPager로 할 수 있습니다. 가장 좋은 회전 목마는 recylerview를 사용하고 있습니다. 하지만 당신은 LayoutManager에 먼저 다음 recylcerview 스크롤의 속도를 변경 CustomLayoutManager 만들기
CustomLayoutManager layoutManager = new CustomLayoutManager(getActivity());
layoutManager.setSpeed(1500f);
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
Recyclerview
만들기 회전 목마
같은 속도를 느리게하는 사용자 정의 할 필요가
활동에서 다음
public class CustomLayoutManager extends LinearLayoutManager {
private float MILLISECONDS_PER_INCH = 1100f;
private Context mContext;
public CustomLayoutManager(Context context) {
super(context);
mContext = context;
}
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, final int position) {
LinearSmoothScroller smoothScroller = new LinearSmoothScroller(mContext) {
@Override
public PointF computeScrollVectorForPosition(int targetPosition) {
return CustomLayoutManager.this.computeScrollVectorForPosition(targetPosition);
}
@Override
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return MILLISECONDS_PER_INCH/displayMetrics.densityDpi;
}
};
smoothScroller.setTargetPosition(position);
startSmoothScroll(smoothScroller);
}
public void setSpeed(float speed){
this.MILLISECONDS_PER_INCH = speed;
}
}
또는 조각, 생성 Runnable
Runnable runNews = new Runnable() {
@Override
public void run() {
try {
top_new_rview.smoothScrollToPosition(++counter);
handler.postDelayed(this, replay);
} catch (Exception e) {
handler.removeCallbacks(runNews);
onError(getActivity(), e);
}
}
};