2010-05-16 41 views
2

我试图把一个TextView,并在表行一个切换按钮,但是,他们似乎没有对齐(按钮的顶部开始约10px的下面,即使身高每一个元素都是相同的TextView的顶部。谁能告诉我为什么吗?Android的布局:为什么不TextView的和一个切换按钮排列

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

     > 
    <TableRow> 
     <AutoCompleteTextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:singleLine="true" 
     android:layout_weight="1" 
     /> 

     <ToggleButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     /> 
     </TableRow> 

     </TableLayout> 

回答

2

的TableRow的行为像的LinearLayout,并试图排列控件沿默认其基线文本,设置android:layout_gravity="center_vertical"(或任何其他重力在你切换按钮设置),如果你想它对准不同。

相关问题