【发布时间】:2013-11-23 19:50:17
【问题描述】:
我有一个位于滚动视图内的文本视图,它可以正常滚动,直到打开软键盘。
当键盘打开时,它就像是随着键盘的高度再次向上滚动。
我的尝试
我在清单中尝试了这个,但产生了完全相同的结果
android:windowSoftInputMode="adjustResize"
然后这个:
android:windowSoftInputMode="adjustPan"
这似乎可行,但问题是它正在向上移动整个屏幕并将标题移出视线。
我也尝试在线性布局中添加以下内容
android:focusable="true"
android:focusableInTouchMode="true"
这只导致应用程序不关注输入字段(EditText)并且键盘没有自动打开,但是当您单击输入字段时,它的行为与以前相同。
这是 XML 文件代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lightGray"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_layout"
android:layout_marginTop="10dip" >
<LinearLayout
android:id="@+id/msg_list_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="@+id/bottom_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:color/background_light">
<Button
android:id="@+id/send_btn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/txt_send" />
<EditText
android:id="@+id/msg_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/send_btn"
android:layout_toLeftOf="@+id/send_btn"
android:inputType="text" >
</EditText>
</RelativeLayout>
有什么建议吗?
【问题讨论】:
-
我遇到了 HorizontalScrollView 的问题。 [查看我的答案][1] [1]:stackoverflow.com/a/28341373/1912919
-
对于 Android 5,请查看此相关帖子:Android - adjust scrollview when keyboard is up for android 5.0 (lollipop)