我的线性布局占用了太多空间。所以我决定把它放在一个 ScrollView 里面。
布局底部有一个 EditText 供用户输入。为了使布局在 AndroidManifest.xml 中为我放置的 Activity 调整大小:
android:windowSoftInputMode="adjustPan"
当我刚刚有一个线性布局时还可以,但现在结合滚动视图我得到一个空白空间,我认为 Android 正在尝试为键盘腾出空间。
布局.xml:
<ScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.appcompat.widget.LinearLayoutCompat
android:isScrollContainer="false"
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"
android:orientation="vertical"
tools:context=".MainActivity"
android:background="@color/colorPrimary">
...
</androidx.appcompat.widget.LinearLayoutCompat>
</ScrollView>