gpt4 book ai didi

android - 键盘可见时滚动内容

转载 作者:太空宇宙 更新时间:2023-11-03 10:37:36 26 4
gpt4 key购买 nike

我的应用程序中有一个登录表单(只是一个用于电子邮件的 EditText 和另一个用于密码的表单,在它的按钮下方)并且因为当焦点在电子邮件上时键盘会隐藏密码,所以我想要用户能够用他的手指滚动,而不仅仅是点击键盘上的下一步按钮。

所以我决定添加一个 ScrollView 并且因为我希望内容与底部对齐,所以我添加了一个 LinearLayout 作为 ScrollView< 的父级 并为 Scrollview 添加重力底部。

布局的 xml 代码是:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/white"
android:layout_width="match_parent" android:layout_height="match_parent">

<ScrollView
android:layout_gravity="bottom"
android:fillViewport="true"
android:layout_width="match_parent" android:layout_height="wrap_content">

<EditText
android:id="@+id/et_name" android:textSize="@dimen/app_text_size_medium" android:textColorHint="@color/white"
android:hint="Enter email" android:inputType="text"
android:paddingTop="8dp"
android:imeOptions="actionNext" android:maxLines="1"
android:textColor="@color/white" android:alpha="0.5"
android:background="@android:color/transparent"
android:layout_width="match_parent" android:layout_height="wrap_content" />

<EditText
android:id="@+id/et_password" android:textSize="@dimen/app_text_size_medium"
android:hint="@string/sign_in_password_hint" android:inputType="textPassword" android:textColorHint="@color/white"
android:textColor="@android:color/white" android:alpha="0.5"
android:background="@android:color/transparent"
android:imeOptions="actionDone" android:maxLines="1"
android:layout_weight="4"
android:layout_width="0dp" android:layout_height="wrap_content" />

<Button
android:id="@+id/btn_signin_submit"
android:text="@string/sign_in_button" android:textColor="@color/white" android:textSize="@dimen/app_text_size_normal"
android:textAllCaps="false"
android:background="@drawable/selector_btn_sign_in"
android:layout_marginLeft="@dimen/spacing_large_app" android:layout_marginRight="@dimen/spacing_large_app"
android:layout_width="match_parent" android:layout_height="wrap_content" />


</LinearLayout>

</ScrollView>

问题是,当一个编辑文本获得焦点时,布局只会“闪烁”键盘上方的所有内容,滚动根本不起作用。

关于如何启用平滑滚动的任何帮助?

最佳答案

您不需要使用 ScrollView 。您只需将这一行添加到您的 mainfest 文件中的 side activity 标签中。android:windowSoftInputMode="adjustPan

关于android - 键盘可见时滚动内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40875233/

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