我想通过ID(也就是View),进行 ScrollView 的滚动,但是没有成功。用下面的例子如何实现呢?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/pressMe"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Press me to scroll to A">
<ImageView
android:id="@+id/scrollToMe"
android:layout_height="100dp"
android:layout_width="fill_parent"
android:layout_marginTop="2000dp"
android:background="#f00">
</LinearLayout>
</ScrollView>
你可以关注那个 view,我认为它会自动滚动。
你也可以获得所需要 view 的坐标,滚动到指定的位置。