0
<LinearLayout 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="@drawable/hintergrund"
 >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/display"
    android:orientation="vertical"
     >

    <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:maxLines="1"          
        />

    <Button 
        android:layout_width="fill_parent"
        android:text="bla"
        android:layout_height="wrap_content"
        />

    <TextView 
        android:id="@+id/ergebnis"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        />

</LinearLayout>

</LinearLayout>

こんにちは、私はAndroid開発、特にXMLに不慣れです。

EditTextとButtonを画面幅全体に表示したいのですが、エミュレーターの上でコードを実行すると、それらが中央に配置されているが、画面幅の約半分しか表示されないことが示されます。どうすればそれを変更でき、何が間違っているのですか?ありがとうございました

4

1 に答える 1

0

これは機能するはずです:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:backgroun="@drawable/hintergrund"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/display"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:maxLines="1" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="bla" />

        <TextView
            android:id="@+id/ergebnis"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

</LinearLayout>


どうなるか教えてください。

于 2012-12-31T04:07:18.077 に答える