我有一个数据输入类型的 Activity ,我正在使用线性布局来均匀地分隔 TextView 和编辑文本集。然后我有一个 ScrollView ,它应该可以使用户可以在软键盘启动时滚动。
如果我使用 android:fillViewport
linearlayout 工作正常并填充屏幕并均匀分布每个项目但是当键盘出现并停止均匀分布每个项目时。如果我使用 android:windowSoftInputMode="stateVisible|adjustPan"
那么 linearlayout 仍然展开但 ScrollView 不再工作(从所有 Unresolved 帖子来看,我不认为你可以拥有带有 adjustPan 的工作 ScrollView )
有什么方法可以在 ScrollView 中设置线性布局,使项目均匀分布并且在软键盘启动时仍然可以工作而不更改线性布局?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport
>
<LinearLayout
android:gravity="left"
android:orientation="vertical"
android:id="@id/tab2"
android:paddingLeft="40.0dip"
android:paddingTop="0.0dip"
android:paddingRight="40.0dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0">
<TextView
android:id="@id/textViewBrand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/brand" />
<AutoCompleteTextView
android:id="@id/editTextBrand"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</AutoCompleteTextView>
</LinearLayout>
...more linearlayouts with textview and edittext to be spaced out evenly
最佳答案
在 ScrollView 中设置属性 android:fillViewport="true"它将起作用
关于android - ScrollView 内的线性布局,分布均匀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18077954/