2017-04-06 4 views
1

RecyclerViewoffset으로 특정 위치로 스크롤하고 싶습니다. 이제 scrollToPositionWithOffset(position, offset)을 사용하고 있으며 스크롤이 너무 빠르며 스크롤 속도를 제어 할 수없는 경우를 제외하고는이 방법이 잘 작동합니다. smoothScrollToPosition()을 사용해 보았지만 오프셋이 필요합니다. 누군가가 scrollToPositionWithOffset()을 사용할 때 스크롤 속도를 어떻게 제어 할 수 있습니까?오프셋을 사용한 RecyclerView 스크롤 속도

답변

-1

recyclerviewnestedScrollview에 넣으면 부드럽게 스크롤합니다.

+0

와우 ... 내 작품은 부드럽고 아무 것도 사용하지 않았습니까? * 호기심 * –

+1

질문에 대답 할 수 있지만 _how_ 및/또는 _why_에 대한 추가 [컨텍스트] (https://meta.stackexchange.com/q/114762)를 제공하면 문제를 해결할 수있어 응답의 장기적인 가치가 향상됩니다. 지금 묻는 사람뿐만 아니라 앞으로 독자에게 질문에 답하고 있다는 것을 기억하십시오! 귀하의 답변을 설명에 추가하고, 어떤 제한 및 가정이 적용되는지를 알려주십시오 (http://stackoverflow.com/posts/43255822/edit). 또한 왜이 답변이 다른 사람들보다 더 적절한지 언급하지 않아도됩니다. –

1

플링 속도를 제어해야하는 경우 사용자 자신의 리사이클링 구현을 구현해야합니다.

public class CustomRecyclerView extends RecyclerView { 

Context context; 

public CustomRecyclerView(Context context) { 
    super(context); 
    this.context = context; 
} 

public CustomRecyclerView(Context context, AttributeSet attrs) { 
    super(context, attrs); 
} 

public CustomRecyclerView(Context context, AttributeSet attrs, int defStyle) { 
    super(context, attrs, defStyle); 
} 

@Override 
public boolean fling(int velocityX, int velocityY) { 

    velocityY *= 0.7; 
    // velocityX *= 0.7; for Horizontal recycler view. comment velocityY line not require for Horizontal Mode. 

    return super.fling(velocityX, velocityY); 
    } 

}