在表格布局中设置列宽的最有效方法是什么?

时间:2015-01-12 08:29:31

标签: android android-tablelayout

我正在从事房地产申请。

在房子的详细页面上,我显示了很多关于房子的信息。 但我收到一些警告,说我的布局需要很长时间才能呈现,所以我希望改进我的布局。

这是我想要改进的布局的一部分:

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingLeft="12dp"
        android:paddingRight="12dp">

        <!-- General -->
        <include
            layout="@layout/view_property_properties_general"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <!-- Interior -->
        <include
            layout="@layout/view_property_properties_interior"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <!-- Financial -->
        <include
            layout="@layout/view_property_properties_financial"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <!-- Terrain -->
        <include
            layout="@layout/view_property_properties_terrain"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <!-- Energy -->
        <include
            layout="@layout/view_property_properties_energy"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

</LinearLayout>

这是一般属性布局的样子(我使用可扩展面板,因此用户可以显示/隐藏):

<widgets.ExpandablePanel
android:id="@+id/general_container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:content="@+id/content"
app:handle="@+id/tv_general_title">

<TextView
    android:id="@+id/tv_general_title"
    style="@style/property_detail_title_style"
    android:text="@string/general_properties"/>

<TableLayout
    android:id="@id/content"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/estate_type"/>

        <TextView
            android:id="@+id/tv_estate_type"
            style="@style/property_detail_value_style"
            tools:text="House"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/total_living_area"/>

        <TextView
            android:id="@+id/tv_liveable_area"
            style="@style/property_detail_value_style"
            tools:text="145 m²"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/number_of_facades"/>

        <TextView
            android:id="@+id/tv_number_of_facades"
            style="@style/property_detail_value_style"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/number_of_living_units"/>

        <TextView
            android:id="@+id/tv_number_of_living_units"
            style="@style/property_detail_value_style"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/number_of_floors"/>

        <TextView
            android:id="@+id/tv_number_of_floors"
            style="@style/property_detail_value_style"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/number_of_extra_buildings"/>

        <TextView
            android:id="@+id/tv_number_of_extra_buildings"
            style="@style/property_detail_value_style"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/parking_spots_inside"/>

        <TextView
            android:id="@+id/tv_parking_spots_inside"
            style="@style/property_detail_value_style"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/parking_spots_outside"/>

        <TextView
            android:id="@+id/tv_parking_spots_outside"
            style="@style/property_detail_value_style"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/condition_of_the_building"/>

        <TextView
            android:id="@+id/tv_condition_of_the_building"
            style="@style/property_detail_value_style"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/length_on_streetside"/>

        <TextView
            android:id="@+id/tv_width_on_streetside"
            style="@style/property_detail_value_style"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/year"/>

        <TextView
            android:id="@+id/tv_build_year"
            style="@style/property_detail_value_style"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/investment_property"/>

        <TextView
            android:id="@+id/tv_investment_property"
            style="@style/property_detail_value_style"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/public_sale_property"/>

        <TextView
            android:id="@+id/tv_public_sale"
            style="@style/property_detail_value_style"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/newbuild"/>

        <TextView
            android:id="@+id/tv_newbuild"
            style="@style/property_detail_value_style"/>

    </TableRow>

    <TableRow>

        <TextView
            style="@style/property_detail_label_style"
            android:text="@string/seasight"/>

        <TextView
            android:id="@+id/tv_seasight"
            style="@style/property_detail_value_style"/>

    </TableRow>
</TableLayout>

这些是样式:

 <style name="property_detail_label_style">
    <item name="android:textSize">@dimen/between_small_and_medium_fontsize</item>
    <item name="android:textColor">@color/gray_6</item>
    <item name="android:layout_width">0dp</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_weight">0.6</item>
    <item name="android:paddingRight">10dp</item>
</style>

<style name="property_detail_value_style">
    <item name="android:textSize">@dimen/between_small_and_medium_fontsize</item>
    <item name="android:textColor">@color/gray_6</item>
    <item name="android:layout_width">0dp</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_weight">0.4</item>
    <item name="android:gravity">left|center_vertical</item>
</style>

正如您所看到的,我正在给出“标签”标签。 TextView和&#39;值&#39; TextView一个重量。我知道重量很贵,但有哪些替代方案呢?

这就是它的样子:

enter image description here

0 个答案:

没有答案