1

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>
4

2 に答える 2

2
<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"

問題を解決します。
回答ありがとうございます。

于 2012-10-10T11:34:41.493 に答える
0

これは、スクロールビューのサイズを変更できるためです。代わりに、スクロールビューの高さを match_parent に設定してみてください。

また、スクロールビュー内で android:fillViewport="true" を設定してみてください。

また、マニフェストのアクティビティ タグ内に次のようなものを追加することもありませんandroid:windowSoftInputMode="adjustResize"。マニフェスト内に以下がある場合は、それを削除してください。

おそらくマニフェストを構成する必要があります。ソフト キーボードで可能な構成のリストを次に示します。android:windowSoftInputMode="adjustPan"使いたいのかもしれません。

于 2012-10-09T11:35:48.207 に答える