简体   繁体   English

TableLayout单元格大小

[英]TableLayout cell size

I have made a TableLayout and it basically looks like this: 我做了一个TableLayout,它基本上看起来像这样:

在此处输入图片说明

Problem is, that there is too much space between the ":" and the numbers and sometimes the number wont fit in the screen. 问题是,“:”和数字之间的空间太大,有时数字无法容纳在屏幕中。

I want to make the cell with the string ("azimuth" for example) to be smaller. 我想使带有字符串(例如“方位角”)的单元格更小。

Is there someway to do this? 有办法做到这一点吗? The code looks like this (first row for example): 代码如下所示(例如,第一行):

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="bennybegun.measuringapp.MainActivity">

<TableRow
    android:layout_height="wrap_content"
    android:gravity="center_horizontal">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textStyle="bold"
        android:typeface="serif"
        android:textSize="35dp"
        android:text="Angles Table"
        android:gravity="center"></TextView>
</TableRow>

<TableRow
    android:layout_height="wrap_content">

    <TextView
        android:text=""
        android:textSize="20dp"
        android:textStyle="bold"
        android:typeface="serif"></TextView>

</TableRow>

<TableRow
    android:layout_height="wrap_content">
    <TextView
        android:text="Azimuth: "
        android:textSize="20dp"
        android:textStyle="bold"
        android:typeface="serif"></TextView>

    <TextView
        android:id="@+id/rotationx"
        android:text="X...."
        android:textSize="20dp"
        android:textStyle="bold"
        android:typeface="serif"></TextView>


</TableRow>

You didn't specify width attributes for your textviews; 您没有为textview指定width属性;

    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="bennybegun.measuringapp.MainActivity">

    <TableRow
        android:layout_height="wrap_content"
        android:gravity="center_horizontal">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:typeface="serif"
            android:textSize="35dp"
            android:text="Angles Table"
            android:gravity="center"></TextView>
    </TableRow>

    <TableRow
        android:layout_height="wrap_content">
    <!--In your case you know the titles beforehand so you can fix the width-->
        <TextView
 android:layout_width="wrap_content"
            android:text=""
            android:textSize="20dp"
            android:textStyle="bold"
            android:typeface="serif"></TextView>

    </TableRow>

    <TableRow
        android:layout_height="wrap_content">
        <TextView
android:layout_width="wrap_content"
            android:text="Azimuth: "
            android:textSize="20dp"
            android:textStyle="bold"
            android:typeface="serif"></TextView>

        <TextView
android:layout_width="0dp"
            android:id="@+id/rotationx"
            android:text="X...."
            android:textSize="20dp"
            android:textStyle="bold"
android:layout_weight="1"
            android:typeface="serif"></TextView>


    </TableRow>

With this method the values side is supposed to consume all the remaining space. 使用这种方法,值侧应该消耗所有剩余空间。 Check to see if you can let the values span more columns than the titles 检查是否可以让值跨越比标题更多的列

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM