gpt4 book ai didi

Android:在键盘显示上,将 ScrollView 固定到底部

转载 作者:行者123 更新时间:2023-11-29 23:20:25 25 4
gpt4 key购买 nike

目标

当显示键盘时,我希望屏幕上最底部的元素始终可见。

当前实现

我尝试过的当前实现(如下所述)在允许内容滚动方面发挥了作用;但是,我未能将 ScrollView 默认设置为位于滚动条的底部。

AndroidManifest.xml

 <activity
android:name=".OnboardingActivity"
android:configChanges="orientation"
android:windowSoftInputMode="stateVisible|adjustResize"
android:label="@string/title_activity_onboarding"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />

fragment

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical">

<include
layout="@layout/toolbar_default" />

<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:orientation="vertical">


<!-- Here are a bunch of elements, the bottommost of which I would like visible when the keyboard is shown -->

</LinearLayout>

</ScrollView>

</LinearLayout>

最佳答案

在我的脑海中,这就是我要实现它的方式。

检查软键盘可见性。来自 this ,您可以获得可见性状态。如果键盘可见,请执行此操作:

scrollView.fullScroll(View.FOCUS_DOWN);

干杯!

关于Android:在键盘显示上,将 ScrollView 固定到底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54432091/

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