0
我正在開發Sudoku遊戲,並且遇到了textViews高度的問題。和任何Sudoku一樣,用戶可以選擇輸入一個數字或者提示一些提示。數字與Fontsize 14一起工作良好,但是當我將提示字體大小更改爲7(dip或sp)時,儘管周圍有很多空間,但textView高度增加了(對於字體大小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>
你能後的你有大小14和大小7字體看到的截圖? – slayton
@slayton:對不起,我是stackoverflow的新用戶,我目前尚未發佈圖片。但是,如果我更改了textSize(在運行時或在佈局查看器中),則整行的高度會增加。 –
考慮使用gridview而不是tableview – slayton