0

私はAndroid開発ではかなり新しいです。私がやりたいことは、TextView-CheckBox のいくつかのペアを配置して、それぞれが 1 つの別々の行になるようにすることです。

<TextView> ................ <CheckBox>
<TextView> ................ <CheckBox>
<TextView> ................ <CheckBox>

TextView左側とCheckBox右側にある必要があります。また、「About」メニュー項目を一番下に配置したいと思います。したがって、それは見え、これが私が望むものです:

<TextView> ................ <CheckBox>
<TextView> ................ <CheckBox>
<TextView> ................ <CheckBox>
               <About>

私がこれまで持っていたのは、CheckBox と TextView の 1 つのペアでした。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                tools:context=".MainActivity">

    <TextView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            />

    <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            />

</RelativeLayout>

CheckBox明らかに、とのペアをもう 1 つ追加しようとしたときTextView、失敗しました。それらは表示されませんでした。残念ながら、メニュー項目を必要な場所に追加する方法はまだわかりません。

4

3 に答える 3

0

あなたの行はおそらく互いに上書きしています。試す:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                tools:context=".MainActivity">

    <TextView
            android:id="@textview1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            />

    <CheckBox
            android:id="@+id/checkbox1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            />

    <TextView
            android:id="@textview2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@id/textview1"
            />

    <CheckBox
            android:id="@+id/checkbox2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_below="@id/checkbox2"
            />
    <Button 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="About us"
            android:layout_centerInParent="true"
            android:layout_alignParentBottom="true"
            />
</RelativeLayout>
于 2013-07-12T07:42:22.977 に答える
0

これを試して..

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="3dp" >


<LinearLayout
android:id="@+id/llMain"    
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="3dp" >


    <RelativeLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:layout_margin="5dp"
            android:background="#ffdddddd"
            >

    <TextView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:text="Text 1"
            android:textColor="#000000"
            android:layout_centerInParent="true"
            />

    <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerInParent="true"
            />

    </RelativeLayout>

      <RelativeLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:padding="10dp"
            android:background="#ffdddddd"
            >

    <TextView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:text="Text 2"
            android:textColor="#000000"
            android:layout_centerInParent="true"
            />

    <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerInParent="true"
            />

    </RelativeLayout>


        <RelativeLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:layout_margin="5dp"
            android:background="#ffdddddd"
            >

    <TextView

            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:text="Text 3"
            android:textColor="#000000"
            android:layout_centerInParent="true"
            />

    <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerInParent="true"
            />

    </RelativeLayout>

 </LinearLayout>


<Button 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="About us"
    android:layout_centerInParent="true"
    android:padding="10dp"
    android:layout_below="@+id/llMain"/>


</RelativeLayout>
于 2013-07-12T07:44:47.627 に答える
0

このように TableLayout を使用してみてください。

<TableLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:layout_marginTop="10dip">
        <TableRow                               
             android:layout_marginTop="10dip">                                
           <TextView
               android:layout_width="0dp"
               android:layout_weight="0.7"
               android:layout_height="wrap_content"                  
               android:gravity="right"  
               android:paddingBottom="10dp"
               android:text="label1:"
               android:textColor="#372c24" />   
            <CheckBox
                android:id="@+id/checkbox1"
                android:layout_width="0dp"
                android:layout_weight="0.3"
                android:layout_height="wrap_content"                  
                android:gravity="left" />
        </TableRow>
        <TableRow                           
             android:layout_marginTop="10dip">                                
           <TextView
               android:layout_width="0dp"
               android:layout_weight="0.7"
               android:layout_height="wrap_content"                  
               android:gravity="right"  
               android:paddingBottom="10dp"
               android:text="label2:"
               android:textColor="#372c24" />   
            <CheckBox
                android:id="@+id/checkbox2"
                android:layout_width="0dp"
                android:layout_weight="0.3"
                android:layout_height="wrap_content"                  
                android:gravity="left" />
        </TableRow>
        <TableRow 
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="20dp">        
            <Button
                 android:id="@+id/btn_about"        
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="About"
                 android:onClick="About_Click" />
       </TableRow>
</TableLayout>
于 2013-07-12T09:25:20.747 に答える