【发布时间】:2019-07-01 14:33:53
【问题描述】:
我的线性布局占用了太多空间。所以我决定把它放在一个 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>
【问题讨论】:
-
在你的 ScrollView 中使用 android:fillViewport="true"
-
@MilanPansuriya 哇,谢谢它的工作!如果您想提交答案,我会将其标记为正确。
-
我已经添加了我的答案
标签: android xml layout scrollview adjustpan