【问题标题】:Android Layout: Why don't the TextView and a ToggleButton alignAndroid 布局:为什么 TextView 和 ToggleButton 不对齐
【发布时间】:2010-05-16 18:40:30
【问题描述】:

我正在尝试将 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>

【问题讨论】:

    标签: android alignment textview togglebutton


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2012-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-13
      • 2019-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多