2011-08-18 99 views
0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:paddingTop="4dip" android:paddingBottom="6dip" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:orientation="horizontal"> 
    <TableLayout android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
     <TableRow android:layout_width="fill_parent" 
      android:layout_height="20dp" > 
      <TextView android:id="@+id/text_sender" android:textStyle="bold" android:textColor="#ffffff" android:focusable="false" 
       android:layout_width="0dp" android:layout_height="20dp" android:layout_weight=".75" /> 
      <TextView android:id="@+id/text_date" android:text="date" 
       android:layout_width="0dp" android:layout_gravity="right" android:layout_weight=".25" android:focusable="false" 
       android:layout_height="20dp" /> 
     </TableRow> 
     <TableRow android:layout_width="fill_parent" 
      android:layout_height="35dp" android:gravity="top"> 
      <TextView android:id="@+id/text_msg" android:layout_width="0dp" android:layout_weight=".75" 
       android:layout_height="35dp" android:focusable="false" /> 

      <CheckBox android:layout_width="0dp" android:id="@+id/ck_msg" android:layout_weight=".25" 
       android:checked="false" android:layout_height="35dp" android:focusable="false" 
       android:layout_gravity="right" /> 
     </TableRow> 
    </TableLayout> 
</LinearLayout> 

我想aligh他们两位extream权布局对齐复选框和日期textview在表格布局中的权利?

+4

这是更好地提供任何截图如何ü希望 – Pinki

回答

1

这是更好地使用RelativeLayout的这一点。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:paddingTop="4dip" android:paddingBottom="6dip" 
    android:layout_width="fill_parent" android:layout_height="fill_parent"> 

    <TextView android:text="TextSender" 
     android:id="@+id/text_sender" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <TextView android:text="TextDate" 
     android:id="@+id/text_date" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" /> 

    <CheckBox android:id="@+id/checkBox1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_below="@id/text_sender" 
     android:text="" 
     /> 
    <TextView android:text="TextView" 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@id/checkBox1" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@id/text_sender" /> 

</RelativeLayout> 
+0

它适用于设计部分,但我的重量属性没有设置,因为它们是在我的桌面布局中 – Harinder

1

这应该工作..

  <?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:paddingTop="4dip" android:paddingBottom="6dip" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:orientation="vertical"> 
     <TableLayout android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
      android:layout_gravity = "right"> 
        <TableRow android:layout_width="fill_parent" 
         android:layout_height="20dp" 
    android:layout_gravity = "right"> 
         <TextView android:id="@+id/text_sender" android:textStyle="bold" android:textColor="#ffffff" android:focusable="false" 
          android:layout_width="0dp" android:layout_height="20dp" android:layout_weight=".75" /> 
         <TextView android:id="@+id/text_date" android:text="date" 
          android:layout_width="0dp" android:layout_gravity="right" android:layout_weight=".25" android:focusable="false" 
          android:layout_height="20dp" /> 
        </TableRow> 
        <TableRow android:layout_width="fill_parent" 
         android:layout_height="35dp" android:layout_gravity = "right"> 
         <TextView android:id="@+id/text_msg" android:layout_width="0dp" android:layout_weight=".75" 
          android:layout_height="35dp" android:focusable="false" /> 

         <CheckBox android:layout_width="0dp" android:id="@+id/ck_msg" android:layout_weight=".25" 
          android:checked="false" android:layout_height="35dp" android:focusable="false" 
          android:layout_gravity="right" /> 
        </TableRow> 
       </TableLayout> 
</LinearLayout> 
+0

NAA它没有工作 – Harinder

+0

@Dennis ..发生了什么,然后......没有变化呢? – ngesh

+0

没有改变!!其相同 – Harinder