如何解决EditText平移之后被软键盘遮挡的问题

<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">
    <EditText
        android:translationY="500dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />
</LinearLayout>

EditText平移之后,比如这里的android:translationY="500dp"。软键盘弹出后就会遮挡位于屏幕下方的EditText。平移EditText的容器一样会出现这个问题。

不太理解为什么要用translation,没有特别需求的话建议布局里还是不要这样用。线性布局可以直接marginTop,或者关系布局、约束布局给它找个参照不就好了。

至于软键盘遮挡编辑框,网上有很多相关的解答。