我对 ScrollViews 中的 EditText 滚动行为有疑问,如果键盘在它上面打开,通常它会向上滚动滚动内的内容。但是如果你动态填充 ScrollView 内的布局,键盘将整个屏幕推上去,以前任何人都遇到过这个问题。 提前致谢。
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header_area" >
<LinearLayout
android:id="@+id/contentHolder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
此示例正常工作,线性布局在 ScrollView 中滚动,但即使键盘关闭也显示滚动。我不能使用固定高度。
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="fill_parent"
android:layout_height="100dip"
android:layout_below="@+id/header_area" >
<LinearLayout
android:id="@+id/contentHolder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
我尝试了下面的 xml,它在新项目中按预期工作,但在我的项目中向上推了窗口。我发现其他一些人遇到了这个问题,我会尽快分享我找到的解决方案。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/header_area"
android:layout_width="match_parent"
android:layout_height="50dip" >
</RelativeLayout>
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/contentHolder"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
最佳答案
<application
android:icon="@drawable/is_logo_iphone"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
问题是“全屏”主题不支持调整大小。使用
android:theme="@android:style/Theme.Black.NoTitleBar"
解决问题。
感谢您的回答。
关于android - ScrollView 不响应键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12799060/