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

안드로이드 스크롤 시작 위치 지정 질문

0 추천
안녕하세요 안드로이드 ScrollView 안에 TextView를 넣어서

스크롤 기능을 구현하는데요..

시작 위치를 특정 단어를 기준으로 삼고싶습니다.

 

scrollTo(x,y) 를 이용한다는 것은 알겠는데

y좌표를 구하는 문제에 봉착했습니다.

Text 내용이 길어서 자동으로 개행이 되면서 y좌표가 가변적이 되는데

개행을 유지하면서 y좌표를 구하고 싶은데

 

개발자님들의 도움을 요청하고자 합니다.

 

예) 원하는 시작 단어 School

ABSD

ADGaaaa

School :  3번째줄

 

ABSD

ADGaaa

a

School : 개행시 4번째 줄
놀놀이 (120 포인트) 님이 2013년 4월 1일 질문

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월 1일 답변
답변감사드립니다.
ㅎ 저렇게 이용하고 싶은건데 저기서 넘기는 int y가 가변적이라
y 위치를 넘기는 방법을 여쭤본겁니다.^^
감사합니다.
...