Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在表格布局中设置列宽的最有效方法?_Android_Android Tablelayout - Fatal编程技术网

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

Android 在表格布局中设置列宽的最有效方法?,android,android-tablelayout,Android,Android Tablelayout,我正在做一个房地产申请 在房子的详细信息页面上,我显示了很多关于房子的信息。 但我得到一些警告,我的布局需要太长的时间来渲染,所以我希望改善我的布局 这是我想改进的布局部分: <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:p

我正在做一个房地产申请

在房子的详细信息页面上,我显示了很多关于房子的信息。
但我得到一些警告,我的布局需要太长的时间来渲染,所以我希望改善我的布局

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

<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>

这就是“常规属性”布局的外观(我使用的是可扩展面板,用户可以显示/隐藏):


以下是样式:

 <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>

@尺寸/介于小型和中型之间
@颜色/灰色\u 6
0dp
包装内容
0.6
10dp
@尺寸/介于小型和中型之间
@颜色/灰色\u 6
0dp
包装内容
0.4
左|中心|垂直
如你所见,我给了“标签”文本视图和“值”文本视图一个权重。我知道重量很贵,但是有什么替代品呢

这就是它看起来的样子:


“我的布局太长,无法渲染”您从哪里得到该警告?(应该只是一直没有重新完成的布局部分受到权重的影响-也许你的问题不在于这些权重吗?)如果GridLayout和一些技巧()对你有用,你可以试试如果你要在一个表格布局中使用权重,你不妨放下表格布局,用一个简单的线性布局替换每一个表格行,这样,至少可以将视图层次展平1。主要的问题是在深层层次中嵌套了很多视图。快速查看一下,您的视图建议使用
ExpandableListView
,其中“includes”为组行,每个组的实际数据为子行。
 <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>