Android布局:为什么TextView和ToggleButton无法对齐

3
我正在尝试将TextView和ToggleButton放在一行表格中,但它们似乎无法对齐(即使每个元素的高度相同,按钮的顶部离文本视图的顶部约有10像素的差距)。有人能告诉我为什么吗?
<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>
1个回答

2

TableRow 表现类似 LinearLayout,并默认尝试将小部件与文本沿其基线对齐。如果您想要不同的对齐方式,请在 ToggleButton 上设置 android:layout_gravity="center_vertical"(或任何其他重力设置)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接