【问题标题】:Android TableLayout TableRow AlignmentAndroid TableLayout TableRow 对齐
【发布时间】:2014-10-01 08:55:47
【问题描述】:

我正在使用表格布局来显示数据,如下所示。

我想做什么?

我想将所有内容与最大的内容对齐。如下图所示,Pilot 列的内容最多。我的意思是它应该是什么样子;

代码:

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

<TableRow
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <others.TypefaceTextView
        android:id="@+id/txtNo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="1"
        app:customTypeface="fonts/RobotoCondensed-Light.ttf" />

    <others.TypefaceTextView
        android:id="@+id/txtKapi"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="1"
        app:customTypeface="fonts/RobotoCondensed-Light.ttf" />

    <others.TypefaceTextView
        android:id="@+id/txtPilotad"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:maxWidth="115dp"
        android:minWidth="100dp"
        android:text="Y.AVCI"
        app:customTypeface="fonts/RobotoCondensed-Light.ttf" />

    <others.TypefaceTextView
        android:id="@+id/txtSinif"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="S2"
        app:customTypeface="fonts/RobotoCondensed-Light.ttf" />

    <others.TypefaceTextView
        android:id="@+id/txtZaman"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="17:45:5"
        app:customTypeface="fonts/RobotoCondensed-Light.ttf" />

    <others.TypefaceTextView
        android:id="@+id/txtFark"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="17:45:5"
        app:customTypeface="fonts/RobotoCondensed-Light.ttf" />

    <others.TypefaceTextView
        android:id="@+id/txtOndeki"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="17:45:5"
        app:customTypeface="fonts/RobotoCondensed-Light.ttf" />
</TableRow>

【问题讨论】:

    标签: android alignment android-tablelayout


    【解决方案1】:

    我想我知道你想做什么。试着给所有的价值一个权重,这样它们就留在同一个区域。您可能必须使用权重值来满足您的需求。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-14
    • 1970-01-01
    • 1970-01-01
    • 2012-05-17
    • 1970-01-01
    • 2012-08-24
    • 2015-05-01
    • 2012-03-11
    相关资源
    最近更新 更多