2012-03-17 5 views
0

대화 상자의 내용보기로 설정된 XML에서 다음과 같은 레이아웃을 설정했습니다. 내가하려고하는 것은 두 개의 단추가 가운데에 놓 이도록하기 위함입니다. 그들이 있지만, 내가 그들에게 무엇을 하든지 그들은 왼쪽에 머물러 있습니다. 이것은 대화 안에있는 것과 관련이 있습니까? 어떻게 해결할 수 있습니까?대화 상자 요소 정렬

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="10dip" 
    android:background="#FF9E00" 
    android:orientation="vertical"> 

    <TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="#A0DB84"> 
    <TextView android:id="@+id/creatediagtxt" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="TEST"/> 
    </TableRow> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="#004884"> 

<Button android:id="@+id/Button01" 
android:layout_width="wrap_content" android:layout_height="wrap_content" 
android:text="Cancel" android:layout_gravity="center"/> 

<Button android:id="@+id/Button02" 
android:layout_width="wrap_content" android:layout_height="wrap_content" 
android:text="Done" /> 

</TableRow> 

</TableLayout> 

답변

2

당신은 layout_weight 함께 놀러 수 있습니다. 예 :

<TableRow 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#004884" 
    android:layout_weight="1"> 

<Button android:id="@+id/Button01" 
    android:layout_width="wrap_content" android:layout_height="wrap_content" 
    android:text="Cancel" android:layout_weight="0.5"/> 

<Button android:id="@+id/Button02" 
    android:layout_width="wrap_content" android:layout_height="wrap_content" 
    android:text="Done" android:layout_weight="0.5" /> 

</TableRow> 
+0

정말 고맙습니다. – nexus490

+0

좋은 답변님께. – Hasmukh

관련 문제