ScrollViews の EditText スクロール動作に問題があります。通常、キーボードがその上で開くと、スクロール内のコンテンツがスクロールアップします。しかし、スクロールビュー内のレイアウトを動的に埋めると、キーボードが画面全体を押し上げ、他の誰かが以前にこの問題を抱えていました。前もって感謝します。
<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
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>