0

レイアウト ヘッダーのボタンとテキスト ビューの間にセパレータを追加したいのですが、2 つのボタンとテキスト ビューが含まれています。それらの間にセパレータを追加するにはどうすればよいですか?

<RelativeLayout 
 android:layout_width="fill_parent"
 android:layout_height="50px"
 android:layout_gravity="fill_horizontal"
 android:background="@color/Blue" 
 android:orientation="horizontal" >

 <Button
    android:id="@+id/Back"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:layout_marginLeft="5dp"
    android:background="@color/Blue" 
    android:textSize="20sp" 
    android:textColor="@color/White" 
    android:text=" Back"
   />


<TextView
    android:id="@+id/header_text"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center" 
    android:layout_toLeftOf="@+id/Exit"
    android:layout_toRightOf="@+id/Back"
    android:textSize="20sp" 
    android:textStyle="italic" 
    android:typeface="serif" 
    android:background="@color/Blue" 
    android:textColor="@color/White" 
    android:text="Games Apps"/>

 <Button
    android:id="@+id/Exit"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:textSize="20sp" 
    android:layout_centerVertical="true"
    android:background="@color/Blue" 
    android:textColor="@color/White" 
    android:layout_marginRight="5dp"
    android:text=" Exit"
    />

</RelativeLayout>
4

4 に答える 4

0

これを試してみてください。回避策だけがうまくいきました。TableLayout の代わりに他の Layout を実装することで、同じロジックを使用できます。

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



        <TableLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:stretchColumns="*"
                android:showDividers="middle"
                android:layout_centerInParent="true"
                android:background="#000000"
                android:divider="#000000"
                >

            <TableRow>

                <Button
                        android:id="@+id/Back"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="5dp"
                        android:background="#ffffff"
                        android:textSize="20sp"
                        android:text=" Back"
                        />


                <TextView
                        android:id="@+id/header_text"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:gravity="center"
                        android:layout_toLeftOf="@+id/Exit"
                        android:layout_toRightOf="@+id/Back"
                        android:textSize="20sp"
                        android:layout_marginLeft="1dp"
                        android:textStyle="italic"
                        android:background="#ffffff"
                        android:typeface="serif"
                        android:text="Games Apps"/>

                <Button
                        android:id="@+id/Exit"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:textSize="20sp"
                        android:layout_marginLeft="1dp"
                        android:background="#ffffff"
                        android:layout_centerVertical="true"
                        android:layout_marginRight="5dp"
                        android:text=" Exit"
                        />



            </TableRow>
                </TableLayout>



</RelativeLayout>

これを使用する他の問題があることをお知らせください。

于 2013-07-05T07:32:50.110 に答える
0

ボタンとテキストビューの間にビューを追加します

例えば

<View 
    android:layout_width="2dip"
    android:layout_height="fill_parent"
    android:layout_toLeftOf="@id/header_text"
    android:layout_toRightOf="@id/Exit"
    android:padding = "5dip"
    android:background="#FFFF0000"
/>
于 2013-07-05T07:15:15.120 に答える