繁体   English   中英

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

[英]Android Layout: Why don't the TextView and a ToggleButton align

我试图将TextView和ToggleButton放在表格行中,但是,它们似乎没有对齐(即使每个元素的高度相同,按钮的顶部也会在textview顶部下方大约10px处开始。谁能告诉我为什么?

<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>

TableRow的行为与LinearLayout类似,并且默认情况下会尝试将小部件与其基线的文本对齐。 如果您希望它以不同方式对齐,请在ToggleButton上设置android:layout_gravity="center_vertical" (或任何其他重力设置)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM