gpt4 book ai didi

android - 如何确保特定 View 在键盘出现时可见?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:12:42 25 4
gpt4 key购买 nike

我有一个布局,顶部有一个图形,中间有一个 EditText,下面有一个按钮,如下所示:

Example layout

当用户在 EditText 中输入时,我想平移布局以便“Go”按钮仍然可见,即使这意味着从顶部剪掉图像,如下所示:

Wanted layout

我知道 list 中的 windowSoftInputMode="adjustPan",但这不起作用,因为它只能平移到足以让 EditText 可见的程度。有没有办法确保它平移直到按钮也可见?


对于 K_Anas 的评论,这是我的布局。与第一个屏幕截图相比,它删除了所有额外的边距和间距,以消除任何其他问题来源。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<View
android:layout_width="300dp"
android:layout_height="150dp"
android:layout_alignParentTop="true"
android:background="#999"/>

<EditText
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:hint="Sample..."/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Go"/>

</RelativeLayout>

最佳答案

在 Android 开发人员视频群聊中谈到,似乎没有解决此问题的简单方法。共识似乎是重新设计布局,而不是使用 API 来解决问题。

关于android - 如何确保特定 View 在键盘出现时可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10901561/

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