2016-08-04 4 views
1

스크롤 작업을 사용하고 있습니다. content_scrolling.xml에 TextViews 및 버튼이 거의없고 특정 버튼을 클릭 할 때 프로그래밍 방식으로 스크롤/특정 텍스트 뷰로 이동하려고합니다.버튼을 클릭하여 nestedscrollview에서 Textview로 스크롤

또한 x-y 좌표와 관련된 기능을 사용하고 싶지 않습니다.

기본적으로 버튼의 OnClick (보기 v) 기능에서 수행해야 할 작업을 알지 못합니다.

내 content_scrolling.xml

<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
tools:context="com.example.admin.test2.ScrollingActivity" 
tools:showIn="@layout/activity_scrolling" 
android:id="@+id/nsv"> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingTop="20dp"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/l1" 
     android:paddingLeft="40dp"> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="text1" 
      android:id="@+id/b1" /> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="text2"/> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="text3" 
      android:id="@+id/b3" /> 
    </LinearLayout> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="text1" 
     android:id="@+id/t1" 
     android:textSize="50dp" 
     android:paddingTop="40dp" 
     android:layout_below="@+id/l1" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="text2" 
     android:id="@+id/t2" 
     android:textSize="50dp" 
     android:layout_below="@id/t1" 
     android:paddingTop="@dimen/app_bar_height"/> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="text3" 
     android:id="@+id/t3" 
     android:textSize="50dp" 
     android:layout_below="@id/t2" 
     android:paddingTop="@dimen/app_bar_height"/> 
</RelativeLayout> 
</android.support.v4.widget.NestedScrollView> 
+0

"또한 x-y 좌표와 관련된 기능을 사용하고 싶지 않습니다." 왜?!! –

+0

음 .. 거의 모든 활동에서 호출 할 수있는 보편적 인 방법을 찾고 있습니다 ..... x-y 좌표가 특정 활동으로 제한됩니다 –

답변

1

시도는 scrollTo있는 ScrollView의 (x, y)의 방법을 사용한다.

your_scrollview.scrollTo(0, your_TextView.getBottom()); 

your_TextView는 스크롤하려는 textview입니다.

+0

해당 작업이 없습니다 ... –

관련 문제