Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android在同一页面上滚动到ID_Java_Android_Android Layout - Fatal编程技术网

Java Android在同一页面上滚动到ID

Java Android在同一页面上滚动到ID,java,android,android-layout,Java,Android,Android Layout,我在谷歌搜索了一个在同一页面上按ID滚动到元素的例子,但没有成功。我想知道下面的例子是如何实现的 <?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"

我在谷歌搜索了一个在同一页面上按ID滚动到元素的例子,但没有成功。我想知道下面的例子是如何实现的

<?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>

您可以将注意力集中在该视图上,我认为它会自动滚动到该视图


我相信您还可以获取所需视图的坐标并滚动到它们。

您可以关注该视图,我认为它会自动滚动到该视图

我相信你也可以得到你需要的视图坐标并滚动到它们