2011-08-16 16 views
0

画面の下部にテキストビュー、リストビュー、2つのボタンがあります。ここ は、あなたが特にあなたが他の項目に比べて、それらを合わせ試みることができるアイテムを配置しようとしている場合Android:画面の下部に2つのボタンがありません

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
android:id="@+id/widget36" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android" 
> 
<TextView 
android:id="@+id/textView" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="TextView" 
android:gravity="center" 
android:layout_alignParentTop="true" 
android:layout_alignParentLeft="true"> 
</TextView> 
<ListView 
android:id="@+id/listView" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_below="@+id/textView" 
android:layout_alignParentLeft="true" 
> 
</ListView> 
<RelativeLayout 
android:id="@+id/relativeLayout" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:background="@color/darkgray" 
android:layout_alignParentBottom="true" 
android:layout_alignParentLeft="true" 
> 
<Button 
android:id="@+id/doneButton" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="Button" 
android:layout_alignParentBottom="true" 
android:layout_alignParentLeft="true" 
android:layout_weight="0.5"> 
</Button> 
<Button 
android:id="@+id/cancelButton" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="Button" 
android:layout_alignParentTop="true" 
android:layout_alignParentRight="true" 
android:layout_right="@+id/doneButton" 
android:layout_weight="0.5"> 
</Button> 
</RelativeLayout> 
</RelativeLayout> 

君たちは>問題が何であるかを考え出すに

+0

をしたいので、何が実際には問題ですか? – ernazm

+0

私のレイアウトでは、両方のボタンが重なって表示されています:( – user3072848

答えて

0

を私を助けてくださいすることができ、私のレイアウトです。だから、代わりにこれを確認し、私はあなたのコードに変更を加えている

<Button 
    android:id="@+id/doneButton" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Button" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:layout_weight="0.5"> 
    </Button> 
    <Button 
    android:id="@+id/cancelButton" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Button" 
    android:layout_alignParentBottom="true" 
    android:layout_toRightOf="@+id/doneButton" 
    android:layout_weight="0.5"> 
    </Button> 
0

を::

android:layout_alignParentTop="true" 
android:layout_alignParentLeft="true" 

あなたは使用することができwrap_contentするlayout_width:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
android:id="@+id/widget36" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android" 
> 
<TextView 
android:id="@+id/textView" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="TextView" 
android:gravity="center" 
android:layout_above = "@+id/listView" 
> 
</TextView> 
<ListView 
android:id="@+id/listView" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_above="@+id/relativeLayout" 
android:layout_alignParentLeft="true" 
> 
</ListView> 
<RelativeLayout 
android:id="@+id/relativeLayout" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:background="#222222" 
android:layout_alignParentBottom="true" 
android:gravity = "center_horizontal"> 
<Button 
android:id="@+id/doneButton" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="Button1" 
android:layout_weight="0.5"> 
</Button> 
<Button 
android:id="@+id/cancelButton" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="Button2" 
android:layout_toRightOf="@+id/doneButton" 
android:layout_weight="0.5"> 
</Button> 
</RelativeLayout> 
</RelativeLayout> 
0

あなたはアンドロイドを設定する必要があります。両方のボタンをfill_parentに設定すると、両方のボタンが画面と同じ幅になるようになります。

+0

両方のボタンが画面の幅全体に均等に表示されるようにします – user3072848

+0

このリンクをチェック:http://groups.google.com/group/android-developers/ msg/c66e677b79ec5f15 – kyrias

1

は、ほとんどの場合、あなたがこの

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    android:id="@+id/widget36" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
> 
    <TextView 
     android:id="@+id/textView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="TextView" 
     android:gravity="center_horizontal" 
    > 
    </TextView> 
    <ListView 
     android:id="@+id/listView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
    > 
    </ListView> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/darkgray" 
    > 
     <Button 
      android:id="@+id/doneButton" 
      android:text="Button" 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      android:layout_weight="1" 
     > 
     </Button> 
     <Button 
      android:id="@+id/cancelButton" 
      android:layout_height="wrap_content" 
      android:text="Button" 
      android:layout_width="fill_parent" 
      android:layout_weight="1" 
     > 
     </Button> 
    </LinearLayout> 
</LinearLayout> 
+0

画面の下部にあるボタンは、空きスペースを均等に取っていません。 – user3072848

+0

0_0本当ですか?これをテストしたところ、それらは等しいです。 1行以上ですか、それとも上部スペースを取ってもらいたいですか? – ernazm

関連する問題