1

背景画像のあるログインフォームでスクロールビューを使用したいのですが、画像が伸びます。

私のコードは次のようになります:

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
     android:id="@+id/login_layout" >

    <LinearLayout 
        android:layout_width="250dp"
        android:layout_height="270dp"
        android:layout_marginTop="40dp"
        android:gravity="center"
        android:orientation="vertical"
        android:background="@drawable/login" >

        <LinearLayout 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:orientation="vertical" >

            <TextView 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/username_login" />

            <EditText
                android:id="@+id/username_login"
                android:inputType="text"
                android:layout_width="200dp"
                android:layout_height="30dp"
                android:paddingLeft="5dp"
                android:paddingTop="2dp"
                android:background="@drawable/edit_text" />

            <TextView 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/password_login" />

        </LinearLayout>

    </LinearLayout>

</LinearLayout>

</ScrollView>

ユーザー名とパスワードの 2 つのテキスト編集と、ログイン ボタンがあります。

android:background="@drawable/login"

テキスト編集とボタンを保持するレイアウトの背景画像です

何か助けてください?

アクティビティ内に(伸びる)背景を設定したことを知っています

アクティビティ内に背景を設定しています

private void setBackground(){


        LinearLayout layout = (LinearLayout) findViewById(R.id.login_layout);
        layout.setBackgroundDrawable(application.getBackground01());

    }
4

2 に答える 2

1

You can try this code. Hope is will work.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/login_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/login"
    android:gravity="center"
    android:orientation="vertical" >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:layout_width="250dp"
            android:layout_height="270dp"
            android:layout_marginTop="40dp"
            android:gravity="center"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="30dp"
                android:orientation="vertical" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/username_login" />

                <EditText
                    android:id="@+id/username_login"
                    android:layout_width="200dp"
                    android:layout_height="30dp"
                    android:background="@drawable/edit_text"
                    android:inputType="text"
                    android:paddingLeft="5dp"
                    android:paddingTop="2dp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/password_login" />
            </LinearLayout>
        </LinearLayout>
    </ScrollView>

</LinearLayout>
于 2012-07-24T11:58:21.557 に答える