开发者

How to scroll from code to make a view shown in the screen?

I have a ScrollView which contains 1 button and 3 TextViews. Currently the button and the first TextView is shown on the screen and they occupy the whole screen. The second TextView is below the first TextView and is outside of the screen. When user clicks the button, I want the code to scroll the second TextView to be shown on the top of the screen. Could someone tell me how to make it? Thanks!

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" 
android:orientation="vertical"
>


<ScrollView android:id="@+id/scrllvw"
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content"
          android:fadingEdge="none"
           >

       <LinearLayout android:layout_width="fill_parent" 
          android:layout_height="wrap_content"
          android:orientation="vertical" 开发者_如何学编程>
           <Button android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              android:id="@+id/test" />
           <TextView android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              android:id="@+id/text1" />
           <TextView android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              android:id="@+id/text2" />           
           <TextView android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              android:id="@+id/text3" />           
        </LinearLayout>
</ScrollView>
</LinearLayout>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜