I'm working on an real estate application.
On the detail page of a house I display a lot of info about the house. But I'm getting some warnings that my layout takes too long to render so I'm looking to improve my layout.
This is the part of my layout I want to improve:
<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>
This is what the general properties layout looks like (I'm using a expandable panel so the user can show/hide):
<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>
These are the styles:
<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>
As you can see I'm giving the 'label' TextView and the 'value' TextView a weight. I know that weights are expensive but what are the alternatives ?
This is what it looks like: