80+视图 - 为糟糕的表现林特警告 [英] Lint warning for bad performance - 80+ Views

查看:149
本文介绍了80+视图 - 为糟糕的表现林特警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此皮棉警告错误: highscores.xml有不好的表现超过80看法。这是我的高分表具有15行3列。这是精简版的版本我的应用程序,我的付费版本将要举办30行。

我的问题是我如何优化这个code?必须有一个更好的办法。

highscores.xml

 < RelativeLayout的
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    机器人:ID =@ + ID / RelativeLayout的
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:stretchColumns =*
    机器人:方向=垂直
    机器人:以下属性来=16DP
    机器人:paddingRight =16DP
    机器人:paddingTop =5DP
    机器人:paddingBottom会=65dp
    机器人:背景=@可绘制/滚动>

    <的TextView
        机器人:ID =@ + ID /标题
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_alignParentTop =真
        机器人:layout_centerHorizo​​ntal =真
        机器人:TEXTSTYLE =黑体
        机器人:TEXTSIZE =18sp
        机器人:paddingBottom会=10dp
        机器人:paddingTop =65dp/>

    <的LinearLayout
        机器人:ID =@ + ID / LinearLayout中
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_alignParentBottom =真
        机器人:paddingTop =5DP>

        <按钮
            机器人:ID =@ + ID / homeBtn
            机器人:layout_width =0dp
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_weight =1
            机器人:TEXTSIZE =14sp/>

        <按钮
            机器人:ID =@ + ID / clearHS
            机器人:layout_width =0dp
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_weight =1
            机器人:TEXTSIZE =14sp/>
    < / LinearLayout中>

    <滚动型
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:以下属性来=8DP
        机器人:paddingRight =8DP
        机器人:paddingTop =8DP
        机器人:paddingBottom会=8DP
        机器人:背景=@可绘制/ scrollviewborder
        机器人:layout_below =@ ID /标题
        机器人:layout_above =@ ID / LinearLayout中
        机器人:fillViewport =真
        机器人:滚动条=无>

        < TableLayout
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID /多个R1
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R1C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / R1B
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / R2S
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R2C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / R2B
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / R3S
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R3C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / R3B
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / R 45
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R4C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / R4B
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / R,S
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R5C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / R5B
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / R6S
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R6C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / R6B
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / R7S
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R7C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / R7B
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / R8S
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R8C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / R8B
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / r9s
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R9C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / R9B
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / r10s
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R10C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / r10b
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / r11s
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / r11c
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / R11B
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / r12s
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R12C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / R12B
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / R13S
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R13C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / R13B
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / r14s
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R14C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / R14B
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>

            <查看
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =1DP
                机器人:后台=#C2BEBF/>

            <的TableRow
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =1>

                <的TextView
                    机器人:ID =@ + ID / r15s
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =25
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <的TextView
                    机器人:ID =@ + ID / R15C
                    机器人:layout_width =0dip
                    机器人:layout_height =FILL_PARENT
                    机器人:layout_weight =75
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>

                <按钮
                    机器人:ID =@ + ID / r15b
                    机器人:layout_width =WRAP_CONTENT
                    机器人:layout_height =FILL_PARENT
                    机器人:重力=中心
                    机器人:TEXTSIZE =14sp/>
            < /的TableRow>
        < / TableLayout>
    < /滚动型>
< / RelativeLayout的>
 

解决方案

使用的ListView ,而不是 TableLayout 一个滚动型内。这不仅将让你的真正需要根据可用的屏幕尺寸只有尽可能多的行,但你可以摆脱按键,做什么它的按键都应该基于点击列表中的项目来做。

I am getting this lint warning error: highscores.xml has more than 80 views bad for performance. This is my high scores table that has 15 rows and 3 columns. This is the Lite version of my app and my paid version is going to hold 30 rows.

My question is how can I optimize this code? There has to be a better way.

highscores.xml

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relativelayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="*"
    android:orientation="vertical"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="5dp"
    android:paddingBottom="65dp"
    android:background="@drawable/scroll" >

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:textStyle="bold"
        android:textSize="18sp"
        android:paddingBottom="10dp"
        android:paddingTop="65dp" />

    <LinearLayout
        android:id="@+id/linearlayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:paddingTop="5dp" >

        <Button 
            android:id="@+id/homeBtn"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="14sp" />

        <Button 
            android:id="@+id/clearHS"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="14sp" />
    </LinearLayout>

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="8dp"
        android:paddingRight="8dp"
        android:paddingTop="8dp"
        android:paddingBottom="8dp"
        android:background="@drawable/scrollviewborder"
        android:layout_below="@id/title"
        android:layout_above="@id/linearlayout"
        android:fillViewport="true"
        android:scrollbars="none" >

        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r1s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r1c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r1b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r2s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r2c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r2b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r3s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r3c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r3b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r4s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r4c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r4b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r5s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r5c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r5b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r6s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r6c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r6b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r7s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r7c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r7b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r8s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r8c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r8b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r9s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r9c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r9b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r10s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r10c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r10b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r11s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r11c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r11b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r12s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r12c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r12b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r13s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r13c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r13b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r14s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r14c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r14b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>

            <View 
                android:layout_width="fill_parent"
                android:layout_height="1dp"       
                android:background="#C2BEBF" />

            <TableRow
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <TextView
                    android:id="@+id/r15s"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="25"
                    android:gravity="center"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/r15c"
                    android:layout_width="0dip"
                    android:layout_height="fill_parent"
                    android:layout_weight="75"
                    android:gravity="center"
                    android:textSize="14sp" />

                <Button
                    android:id="@+id/r15b"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:textSize="14sp" />
            </TableRow>
        </TableLayout>
    </ScrollView>
</RelativeLayout>

解决方案

Use a ListView instead of a TableLayout inside of a ScrollView. Not only will that allow you to only have as many rows as is really needed based upon available screen size, but you can get rid of the buttons, doing whatever it is the buttons are supposed to do based on clicking on list items.

这篇关于80+视图 - 为糟糕的表现林特警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆