首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TableLayout在不伸展按钮的情况下划分空格?

TableLayout在不伸展按钮的情况下划分空格?
EN

Stack Overflow用户
提问于 2018-02-07 16:03:21
回答 1查看 30关注 0票数 0

我希望按钮保持其原始大小(包装内容),但它们要在该逻辑单元格位置对齐。这有可能吗?我是说,我想要的是,

代码语言:javascript
复制
|[Lisa]_______|[Simpson]____|

不,

代码语言:javascript
复制
|[___Lisa____]|[__Simpson__]|

或,

代码语言:javascript
复制
|[Lisa]|[Simpson]___________|

以下代码不起作用。

代码语言:javascript
复制
<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TableRow>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Lisa"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Simpson"/>
    </TableRow>
EN

回答 1

Stack Overflow用户

发布于 2018-02-07 18:52:05

默认情况下,TableLayout将其项目居中。您可以使用的是LinearLayout,如下所示:

代码语言:javascript
复制
<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Lisa"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Simpson"/>

</LinearLayout>

这会均匀地划分两个按钮的间距,但不会使每个按钮居中。这是它看起来的样子。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48658693

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档