首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TableLayout问题

TableLayout问题
EN

Stack Overflow用户
提问于 2012-09-18 15:13:19
回答 2查看 272关注 0票数 0

我有这个表格布局,前两行有两行,第三行(CustomerAddress)有一行,我想右对齐并占用所有空间。我如何才能做到这一点。我试过gravity = right,但没有成功。

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stretchColumns="*" >

    <TableRow>

        <TextView
            style="@style/CustomerLabelTextView"
            android:gravity="right"
            android:text="@string/customerCode" />

        <TextView
            style="@style/CustomerLabelTextView"
            android:gravity="right"
            android:text="@string/customerName" />
    </TableRow>
    <TableRow>

       <TextView
            android:id="@+id/customerCode"
            style="@style/CustomerTextView"
            android:gravity="right" />

        <TextView
            android:id="@+id/customerName"
            style="@style/CustomerTextView"
            android:gravity="right" />
    </TableRow>

    <TableRow>

        <TextView
            style="@style/CustomerLabelTextView"
            android:gravity="right"
            android:text="@string/customerAddress" />
    </TableRow>
     <TableRow>

        <TextView
            android:id="@+id/customerAddress"
            style="@style/CustomerTextView"
            android:gravity="right" />
    </TableRow>

    <TableRow>

        <TextView
            style="@style/CustomerLabelTextView"
            android:gravity="right"
            android:text="@string/OrganizationName" />

        <TextView
            style="@style/CustomerLabelTextView"
            android:gravity="right"
            android:text="@string/POBox" />
    </TableRow>

    <TableRow>

        <TextView
            style="@style/CustomerLabelTextView"
            android:gravity="right"
            android:text="@string/phone" />

        <TextView
            style="@style/CustomerLabelTextView"
            android:gravity="right"
            android:text="@string/fax" />
    </TableRow>
</TableLayout>

EN

回答 2

Stack Overflow用户

发布于 2012-09-18 17:26:52

好了,开始工作了。对于那些可能遇到这个问题的人,我在下面添加了代码

代码语言:javascript
复制
 <TableRow
        android:gravity="right" >


        <TextView
            android:id="@+id/customerAddress"
            style="@style/CustomerTextView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1.0"
            android:gravity="right" />

    </TableRow>
票数 2
EN

Stack Overflow用户

发布于 2012-09-18 15:22:10

尝试向该TableRow添加android:layout_span="2“。

代码语言:javascript
复制
<TableRow
    android:layout_span="2"
>
    <TextView
        style="@style/CustomerLabelTextView"
        android:gravity="right"
        android:text="@string/customerAddress"
    />
</TableRow>

http://developer.android.com/reference/android/widget/TableRow.LayoutParams.html#attr_android:layout_span

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

https://stackoverflow.com/questions/12472082

复制
相关文章

相似问题

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