我正在尝试在编辑文本获得焦点后调整布局,以便软键盘出现。现在,如果我有很多编辑文本并且键盘出现,最后一个编辑文本将被隐藏,我无法向上滚动。
这是我的布局结构:
模板:
视图(view_1):
我已经尝试了各种组合的
这是我的布局结构:
模板:
<LinearLayout>
<LinearLayout>
// header 1
</LinearLayout>
<LinearLayout>
// header 1
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="vertical">
// where I inflate view_1
</LinearLayout>
<LinearLayout>
// footer
</LinearLayout>
</LinearLayout>
视图(view_1):
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true">
<LinearLayout>
// ...
</LinearLayout>
<LinearLayout>
// ...
</LinearLayout>
<LinearLayout>
<TextView/>
<EditText/>
<TextView/>
<EditText/>
<TextView/>
<EditText/>
<TextView/>
<EditText/>
</LinearLayout>
</LinearLayout>
</ScrollView>
我已经尝试了各种组合的
android:windowSoftInputMode
(在manifest.xml和编程中)。我尝试在滚动视图上设置android:isScrollContainer="false"
,但是没有效果。我还尝试了这个答案,在我的滚动视图中放置一个GlobalLayoutListener,但是当键盘出现时onGlobalLayout不会被调用。而且isKeyboardShown
始终为false。