마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

ListView smoothScrollBy 를 한 아이템씩 가게 하려면 어떻게 해야 할까요

0 추천
리스트뷰의 높이를 60dp, 그리고 리스트 아이템(row)의 높이도 60dp로 설정 했습니다.

 

아이템 하나씩 롤링되는 효과를 좀 만들어보려고 smoothScrollBy를 사용해서 다음아이템을 보여주는데요

 

이게 픽셀이라 그런지 조금씩 어긋나는군요..

 

newsList.smoothScrollBy(newsList.getLastVisiblePosition() + pixelFromDP(60), 1000);

 

//

int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics());

 

이런 방식을 사용했구요...

 

이걸 좀더 정확히 할수 있는 방법 있을까요???
ezmo01 (1,510 포인트) 님이 2013년 4월 5일 질문

1개의 답변

0 추천

 

setSelectionFromTop() 를 사용하시면 되실거에요

 

 

public void setSelectionFromTop (int position, int y)

Added in API level 1

Sets the selected item and positions the selection y pixels from the top edge of the ListView. (If in touch mode, the item will not be selected but it will still be positioned appropriately.)

Parameters
position Index (starting at 0) of the data item to be selected.
y

The distance from the top edge of the ListView (plus padding) that the item will be positioned.

 

 

 

http://developer.android.com/intl/ko/reference/android/widget/ListView.html

Noizbuster (11,970 포인트) 님이 2013년 4월 5일 답변
...