2

私のスクロール ビューには、いくつかの編集テキスト フィールドをさらに含む線形レイアウトが含まれています。一番下の編集テキストフィールドをクリックすると、ソフトキーボードが表示されますが、私の問題は、その編集テキストフィールドをカバーしていることです。これは、Android マニフェスト ファイルで宣言された私のアクティビティです。

<activity android:name="me.example.scrollview.LoginActivity" android:label="@string/title_activity_login" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="stateHidden|adjustResize|adjustPan" > </activity>

これがこのアクティビティの私のlayout.xmlファイルです。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
tools:context=".LoginActivity" >

<ScrollView
    android:id="@+id/login_sv_login_container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:isScrollContainer="true"
    android:background="@android:color/transparent" >

    <LinearLayout
        android:id="@+id/login_ll_container"
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="230dp"
        android:layout_gravity="center_horizontal"
        android:background="@android:color/transparent"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/txt_username"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_gravity="center_horizontal"
            android:background="@drawable/rounded_edittext"
            android:ems="10"
            android:inputType="textEmailAddress"
            android:maxLines="1"
            android:singleLine="true" >

            <requestFocus />
        </EditText>

        <EditText
            android:id="@+id/txt_phone"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/rounded_edittext"
            android:ems="10"
            android:inputType="phone"
            android:maxLines="1"
            android:singleLine="true" />

        <EditText
            android:id="@+id/txt_password"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/rounded_edittext"
            android:ems="10"
            android:inputType="textPassword"
            android:maxLines="1"
            android:singleLine="true" />

        <Button
            android:id="@+id/btn_login"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:layout_marginTop="10dp"
            android:background="@drawable/ic_login"
            android:text="" />
    </LinearLayout>
</ScrollView>

私はAndroidプログラミングに非常に慣れていないので、今私を助けてください。この問題を解決できず、メイン ウィンドウのサイズを変更せずにスクロール ビューをスクロールする方法が見つかりません。ソフト キーボードが表示されたときにスクロール ビューをスクロールさせたいだけです。よろしくお願いします。

ここに画像の説明を入力

4

3 に答える 3

0

YOURSCROLLVIEW.scrollTo(int x, int y) または YOURSCROLLVIEW.smoothScrollTo(int x, int y) を使用してスクロール ビューを適切な座標に移動し、編集テキスト ボックスとキーボードの両方が表示されるようにします。

これらの関数およびその他の scrollview 関数の詳細については、android 開発者リファレンス ページを参照してください。

于 2013-07-15T12:02:11.407 に答える
0

あなたが試すことができます:

ScrollView scroll = (ScrollView)findViewById(R.id.scrollview);
scroll.scrollTo(0, sv.getBottom());

また

scroll.scrollTo(5, 10);
于 2013-07-15T12:05:06.310 に答える
0

以前に指摘した両方の解決策が機能します。ただし、編集テキストが ListView の下部にあり、オンスクリーン キーボードで覆われている場合は、まだ問題が発生する可能性があります。コンテンツがなくなるまでスクロールビューをスクロールできるかどうかはわかりません。

私が見たのは、マニフェストで2つの矛盾するフラグを使用する可能性があることです:

android:windowSoftInputMode="stateHidden|adjustResize|adjustPan" > </activity>

AdjustResize と AdjustPan を組み合わせることはできません。AdjustResizeだけでどのように見えるか試してみてください。これにより、キーボードがビューの一部を覆うことを回避できます。

于 2013-07-15T12:13:10.310 に答える