1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/bkgrndclr">

    <Button
        android="@+id/imgbtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Search Images"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true" />
    <Button
        android="@id/imgbtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Search Web"
        android:layout_alignBottom="@id/imgbtn"
        android:layout_toLeftOf="@id/imgbtn" />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/imgbtn"
        android:layout_alignRight="@id/imgbtn" />
</LinearLayout>

ボタンをビューの下部とその上のテキストボックスに設定しましたが、すべてが直線的に表示されるのはなぜですか。[画像を検索] ボタンが最初に表示され、次に [Web を検索]、次に [テキスト ボックス] が表示されますが、それらは下部に配置されていません。これは私が望んでいるものではありません。

4

3 に答える 3

0

ビューの父がLinearLayoutの場合"android:layout_alignParentBottom =" true ""は意味がありません...線形を相対に変更する必要があります。また、EditTextをボタンの上に配置する場合は、次のようにします。

android:layout_above="@id/imgbtn"

あなたのボタンに異なるIDを与えてください!両方をalignParentBottomに変更します

于 2012-09-30T20:07:53.817 に答える
0

2 番目のボタンで、ボタンの id を に変更し"+@id/imgbtn1"て、最初のボタンと衝突しないようにします。

に変更android:layout_alignBottom="@id/imgbtn"android:layout_alignParentBottom="true"ます。

EditText をどこに配置しますか?

于 2012-09-30T20:06:32.723 に答える
0

あなたは何を望んでいるかを説明していません...しかし、私はあなたが次のような画面の下部にレイアウトが必要だと推測しました:

|                                               |
| (EditText                                   ) |
|                            (Button)  (Button) |
 -----------------------------------------------

レイアウト:

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

    <Button
        android:id="@+id/btnImages"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="Search Images"
         />

    <Button
        android:id="@+id/btnWeb"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toLeftOf="@+id/btnImages"
        android:text="Search Web"
         />

    <EditText
        android:id="@+id/search"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/btnImages"
        android:inputType="text"
         />

</RelativeLayout>
于 2012-09-30T20:19:59.403 に答える