减小字体大小时 TextView 高度会增加

发布于 2024-12-08 23:27:20 字数 9889 浏览 1 评论 0原文

我正在开发数独游戏,并且遇到了文本视图高度的问题。与任何数独一样,用户可以选择输入数字或输入一些提示。数字与 Fontsize 14 配合使用效果很好,但是当我将提示字体大小更改为 7(dip 或 sp)时,尽管周围有很多空间(与字体大小 6 相同,甚至有 1 行文本),textView 高度也会增加)。无论文本大小如何,如何修复 textView 高度。

这是布局部分:

    <TableLayout android:id="@+id/tableLayout1"
    android:layout_marginTop="5dip" android:layout_gravity="center_horizontal" android:layout_height="wrap_content" android:layout_width="wrap_content">
    <TableRow android:layout_width="wrap_content" android:id="@+id/TableRow01" android:layout_height="wrap_content">
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="1" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV00" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:digits="@string/inpt" android:width="30dip" android:text="2"
            android:drawableTop="@drawable/line_h" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV01" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="2" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV02" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="1" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV03" android:paddingLeft="1dip" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:digits="@string/inpt" android:width="30dip" android:text="2"
            android:drawableTop="@drawable/line_h" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV04" android:clickable="true"
            android:height="34dip" android:layout_height="fill_parent"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="2" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV05" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="1" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV06" android:paddingLeft="1dip" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:digits="@string/inpt" android:width="30dip" android:text="2"
            android:drawableTop="@drawable/line_h" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV07" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV08" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip" android:text="1 2 3"></TextView>
    </TableRow>
    <TableRow android:layout_width="wrap_content" android:id="@+id/TableRow02"
        android:layout_height="wrap_content">
        <TextView android:typeface="monospace" android:drawableRight="@drawable/line_v"
            android:digits="@string/inpt" android:width="32dip" android:text="1"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV10" android:clickable="true"
            android:layout_height="fill_parent" android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:digits="@string/inpt" android:width="30dip"
            android:text="2" android:gravity="center" android:layout_width="fill_parent"
            android:textColor="@android:color/black" android:id="@+id/TV11"
            android:clickable="true" android:layout_height="fill_parent"
            android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:drawableRight="@drawable/line_v"
            android:digits="@string/inpt" android:width="32dip" android:text="2"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV12" android:clickable="true"
            android:layout_height="fill_parent" android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:drawableRight="@drawable/line_v"
            android:digits="@string/inpt" android:width="32dip" android:text="1"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV13" android:paddingLeft="1dip" android:clickable="true"
            android:layout_height="fill_parent" android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:digits="@string/inpt" android:width="30dip"
            android:text="2" android:gravity="center" android:layout_width="fill_parent"
            android:textColor="@android:color/black" android:id="@+id/TV14"
            android:clickable="true" android:layout_height="fill_parent"
            android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:drawableRight="@drawable/line_v"
            android:digits="@string/inpt" android:width="34dip" android:text="2"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV15" android:clickable="true"
            android:layout_height="fill_parent" android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:drawableRight="@drawable/line_v"
            android:digits="@string/inpt" android:width="34dip" android:text="1"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV16" android:paddingLeft="1dip" android:clickable="true"
            android:layout_height="fill_parent" android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:digits="@string/inpt" android:width="30dip"
            android:text="2" android:gravity="center" android:layout_width="fill_parent"
            android:textColor="@android:color/black" android:id="@+id/TV17"
            android:clickable="true" android:layout_height="fill_parent"
            android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:drawableRight="@drawable/line_v"
            android:digits="@string/inpt" android:width="34dip" android:text="2"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV18" android:clickable="true"
            android:layout_height="fill_parent" android:height="32dip"></TextView>
    </TableRow>

I'm developing a Sudoku Game and am having problems with textViews' heights. As in any Sudoku, the user has the option to enter a digit or put some hints. Digits work fine with Fontsize 14, but when I change the hint font size to 7 (dip or sp), the textView height is increased although there is a lot of space around (the same for font size 6 and even with 1 line of text). How do I fix the textView height regardless of the textsize.

Here is the layout portion:

    <TableLayout android:id="@+id/tableLayout1"
    android:layout_marginTop="5dip" android:layout_gravity="center_horizontal" android:layout_height="wrap_content" android:layout_width="wrap_content">
    <TableRow android:layout_width="wrap_content" android:id="@+id/TableRow01" android:layout_height="wrap_content">
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="1" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV00" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:digits="@string/inpt" android:width="30dip" android:text="2"
            android:drawableTop="@drawable/line_h" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV01" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="2" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV02" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="1" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV03" android:paddingLeft="1dip" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:digits="@string/inpt" android:width="30dip" android:text="2"
            android:drawableTop="@drawable/line_h" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV04" android:clickable="true"
            android:height="34dip" android:layout_height="fill_parent"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="2" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV05" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="1" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV06" android:paddingLeft="1dip" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:digits="@string/inpt" android:width="30dip" android:text="2"
            android:drawableTop="@drawable/line_h" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV07" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV08" android:clickable="true"
            android:layout_height="fill_parent" android:height="34dip" android:text="1 2 3"></TextView>
    </TableRow>
    <TableRow android:layout_width="wrap_content" android:id="@+id/TableRow02"
        android:layout_height="wrap_content">
        <TextView android:typeface="monospace" android:drawableRight="@drawable/line_v"
            android:digits="@string/inpt" android:width="32dip" android:text="1"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV10" android:clickable="true"
            android:layout_height="fill_parent" android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:digits="@string/inpt" android:width="30dip"
            android:text="2" android:gravity="center" android:layout_width="fill_parent"
            android:textColor="@android:color/black" android:id="@+id/TV11"
            android:clickable="true" android:layout_height="fill_parent"
            android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:drawableRight="@drawable/line_v"
            android:digits="@string/inpt" android:width="32dip" android:text="2"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV12" android:clickable="true"
            android:layout_height="fill_parent" android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:drawableRight="@drawable/line_v"
            android:digits="@string/inpt" android:width="32dip" android:text="1"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV13" android:paddingLeft="1dip" android:clickable="true"
            android:layout_height="fill_parent" android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:digits="@string/inpt" android:width="30dip"
            android:text="2" android:gravity="center" android:layout_width="fill_parent"
            android:textColor="@android:color/black" android:id="@+id/TV14"
            android:clickable="true" android:layout_height="fill_parent"
            android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:drawableRight="@drawable/line_v"
            android:digits="@string/inpt" android:width="34dip" android:text="2"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV15" android:clickable="true"
            android:layout_height="fill_parent" android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:drawableRight="@drawable/line_v"
            android:digits="@string/inpt" android:width="34dip" android:text="1"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV16" android:paddingLeft="1dip" android:clickable="true"
            android:layout_height="fill_parent" android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:digits="@string/inpt" android:width="30dip"
            android:text="2" android:gravity="center" android:layout_width="fill_parent"
            android:textColor="@android:color/black" android:id="@+id/TV17"
            android:clickable="true" android:layout_height="fill_parent"
            android:height="32dip"></TextView>
        <TextView android:typeface="monospace" android:drawableRight="@drawable/line_v"
            android:digits="@string/inpt" android:width="34dip" android:text="2"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV18" android:clickable="true"
            android:layout_height="fill_parent" android:height="32dip"></TextView>
    </TableRow>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只想待在家 2024-12-15 23:27:20

我找到了问题的解决方案,无需重做我的代码&使用 gridview 进行设计(感谢 slayton 的建议,但我找到了一个更简单的解决方法)。

我不完全明白为什么,但在玩弄了textviews的属性之后,我发现当我将一个textview的textsize更改为7(或实际上任何其他值)时,我需要将其layoutheight更改为Fill_Parent(但保留所有textViews)在大小为 14 且布局高度为 Wrap_Content 的行中)。我以编程方式执行此操作。新的布局是

    <TableLayout android:id="@+id/tableLayout1"
    android:layout_marginTop="5dip" android:layout_gravity="center_horizontal" android:layout_height="wrap_content" android:layout_width="wrap_content">
    <TableRow android:layout_width="fill_parent" android:id="@+id/TableRow01" android:layout_height="wrap_content">
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="1" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV00" android:clickable="true"
            android:height="34dip" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:digits="@string/inpt" android:width="30dip" android:text="2"
            android:drawableTop="@drawable/line_h" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV01" android:clickable="true"
            android:height="34dip" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="2" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV02" android:clickable="true"
            android:height="34dip" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="1" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV03" android:paddingLeft="1dip" android:clickable="true"
            android:height="34dip" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:digits="@string/inpt" android:width="30dip" android:text="2"
            android:drawableTop="@drawable/line_h" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV04" android:clickable="true"
            android:height="34dip" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="2" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV05" android:clickable="true"
            android:height="34dip" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="1" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:textColor="@android:color/black"
            android:id="@+id/TV06" android:paddingLeft="1dip" android:clickable="true"
            android:height="34dip" android:layout_width="fill_parent" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:digits="@string/inpt" android:width="30dip" android:drawableTop="@drawable/line_h" android:textColor="@android:color/black"
            android:id="@+id/TV07" android:clickable="true"
            android:height="34dip" android:layout_width="fill_parent" android:maxHeight="34dip" android:maxWidth="30dip" android:gravity="center" android:text="2" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:textColor="@android:color/black"
            android:id="@+id/TV08" android:clickable="true"
            android:height="34dip" android:maxHeight="34dip" android:layout_width="fill_parent" android:gravity="center" android:text="2" android:layout_height="wrap_content"></TextView>
    </TableRow>

我使用代码来更改大小&布局高度在一起:

    tv.setTextSize(7);
tv.setLayoutParams(new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));


    tv.setTextSize(14);
tv.setLayoutParams(new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 

I found a solution to my question without the need to redo my code & design with gridview (thanks slayton for your suggestion, but I found an easier workaround).

I don't completely understand why but after playing around with the textviews' properties, I found that when I change the textsize of one textview to 7 (or any other value actually) I need to change its layoutheight to Fill_Parent (but keep all textViews in the row with size 14 with layoutheight Wrap_Content). I do this programmatically. The new layout is

    <TableLayout android:id="@+id/tableLayout1"
    android:layout_marginTop="5dip" android:layout_gravity="center_horizontal" android:layout_height="wrap_content" android:layout_width="wrap_content">
    <TableRow android:layout_width="fill_parent" android:id="@+id/TableRow01" android:layout_height="wrap_content">
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="1" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV00" android:clickable="true"
            android:height="34dip" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:digits="@string/inpt" android:width="30dip" android:text="2"
            android:drawableTop="@drawable/line_h" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV01" android:clickable="true"
            android:height="34dip" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="2" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV02" android:clickable="true"
            android:height="34dip" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="1" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV03" android:paddingLeft="1dip" android:clickable="true"
            android:height="34dip" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:digits="@string/inpt" android:width="30dip" android:text="2"
            android:drawableTop="@drawable/line_h" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV04" android:clickable="true"
            android:height="34dip" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="2" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:layout_width="fill_parent" android:textColor="@android:color/black"
            android:id="@+id/TV05" android:clickable="true"
            android:height="34dip" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:text="1" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:gravity="center"
            android:textColor="@android:color/black"
            android:id="@+id/TV06" android:paddingLeft="1dip" android:clickable="true"
            android:height="34dip" android:layout_width="fill_parent" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:digits="@string/inpt" android:width="30dip" android:drawableTop="@drawable/line_h" android:textColor="@android:color/black"
            android:id="@+id/TV07" android:clickable="true"
            android:height="34dip" android:layout_width="fill_parent" android:maxHeight="34dip" android:maxWidth="30dip" android:gravity="center" android:text="2" android:layout_height="wrap_content"></TextView>
        <TextView android:typeface="monospace" android:drawableBottom="@drawable/line_h"
            android:drawableRight="@drawable/line_v" android:digits="@string/inpt"
            android:width="34dip" android:drawableTop="@drawable/line_h"
            android:drawableLeft="@drawable/line_v" android:textColor="@android:color/black"
            android:id="@+id/TV08" android:clickable="true"
            android:height="34dip" android:maxHeight="34dip" android:layout_width="fill_parent" android:gravity="center" android:text="2" android:layout_height="wrap_content"></TextView>
    </TableRow>

And I use code to change the size & the layoutheight together:

    tv.setTextSize(7);
tv.setLayoutParams(new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));


    tv.setTextSize(14);
tv.setLayoutParams(new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文