gpt4 book ai didi

android - Action 发生后将焦点设置在 ScrollView 的顶部android

转载 作者:太空宇宙 更新时间:2023-11-03 11:51:57 25 4
gpt4 key购买 nike

在我的应用程序中,我正在进行一些计算。整个布局都在 ScrollView 中。

结果显示在顶部。 xml是这样的:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/back2back"
>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="526dp"
android:background="@drawable/back4"
android:orientation="vertical" >

<TextView
android:id="@+id/nothing"
android:layout_width="181dp"
android:layout_height="51dp"
android:layout_gravity="center"

android:textColor="#000000"
android:textStyle="bold" />

rest of the xml
</LinearLayout>
</ScrollView>

所以我希望在按下计算按钮时将屏幕的焦点设置到我的页面的顶部(或者更具体地在上部 TextView 中),以便用户能够看到结果。我在 SO 中搜索但没有找到类似的东西。

最佳答案

如果我理解您的问题,只需调用:

scrollView.scrollTo(0, 0);

在您计算 Button 的 OnClickListener 中。

关于android - Action 发生后将焦点设置在 ScrollView 的顶部android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11333860/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com