gpt4 book ai didi

android - 如何在 Android 的不同设备中打开键盘时使 EditText 自动调整大小

转载 作者:行者123 更新时间:2023-11-30 00:58:55 25 4
gpt4 key购买 nike

当我在我的应用程序上打开 EditText 时,我看到我的 EditText 打开为全屏。当我专注于 EditText 时,我需要为我的键盘自动调整此字段的大小

example of situation

我的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/etFName"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="top"
android:singleLine="false"
android:inputType="textMultiLine"
android:isScrollContainer="false" />
<Button
android:id="@+id/btnCancelPost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Cancel" />

`

最佳答案

将此代码添加到您在 AndroidManifest 文件中的 Activity

android:windowSoftInputMode="adjustResize"

关于android - 如何在 Android 的不同设备中打开键盘时使 EditText 自动调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39740236/

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