edittext在键入文本时返回到布局的顶部

mtb9vblg  于 2021-08-20  发布在  Java
关注(0)|答案(0)|浏览(165)

在相对布局(包含在滚动视图中)中添加edittext视图时,输入文本会将用户带回活动顶部(捕捉到屏幕顶部),使用户无法看到他们正在键入的内容。
问题的复制
以下是该问题的最低复制版本:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".MainActivity"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <RelativeLayout
        android:layout_height="match_parent"
        android:layout_width="match_parent">

        <ImageView
            android:layout_width="100dp"
            android:layout_height="1000dp"
            android:src="@color/purple_500"/>
        <EditText
            android:layout_width="400dp"
            android:layout_height="100dp"
            android:translationY="800dp"/>

    </RelativeLayout>

</ScrollView>

到目前为止我都试过了
到目前为止,我已经尝试添加 <activity android:windowSoftInputMode="stateVisible|adjustResize" .> 虽然我找不到其他发生这种情况的案例,但是它没有任何区别,也没有填充edittext。
添加 wrap_contentandroid:layout_height="", 没有重新考虑这个问题
编辑
我需要在线性布局中包含编辑文本,在相对布局中包含编辑文本,如图所示-https://stackoverflow.com/questions/40316454/edittext-moves-textview-out-of-the-screen-when-they-keyboard-is-opening

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题