有没有什么办法,使表列等于总宽度的几分之几? [英] Is there any way to make table columns equal to a fraction of the total width?

查看:262
本文介绍了有没有什么办法,使表列等于总宽度的几分之几?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,在我的学习我只遇到过小号preading列大小相等,从而一/二更高的优先级,因为他们需要,或者设置手动列的大小采取尽可能多的空间。

So far in my learning I have only come across spreading column sizes equally, giving one/two a higher priority to take as much space as they need, or setting the size of a column manually.

我想知道是否有无论如何设置列大小的机器人是总表大小的一小部分。我想把它分成六分之。 1/6为第一列,3/6为用于第三第二列和2/6

I was wondering if there was anyway of setting a column size in Android to be a fraction of the total table size. I want to split it into sixths. 1/6 for the first column, 3/6 for the second column and 2/6 for the third.

有没有办法做到这一点?

Is there any way to do this?

推荐答案

您可以通过使用<一个做到这一点href="http://developer.android.com/reference/android/widget/TableRow.LayoutParams.html#attr_android%3alayout_span">android:layout_span

下面是一个例子:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="*">

    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TextView
            android:background="#aa0000"
            android:text="1/6"
            android:gravity="center_horizontal"/>
        <TextView
            android:background="#00aa00"
            android:text="3/6"
            android:gravity="center_horizontal" 
            android:layout_span="3"/>
        <TextView
            android:background="#0000aa"
            android:text="2/6"
            android:gravity="center_horizontal"
            android:layout_span="2"/>
        </TableRow>
</TableLayout>

这篇关于有没有什么办法,使表列等于总宽度的几分之几?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆