4

警告を生成する(120以上のビュー)を超える特定の画面(レイアウト)を持つAndroidアプリケーションを作成しています:

   "main.xml has more than 80 views, bad for performance"

私は26日に組織されたたくさんの、、TextViewsグループEditTextsを持っています。RadioButtonsTableRows

アプリケーションのパフォーマンスを向上させ、警告を削除するためにできることはありますか?

ソース: main.xml_capture

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout00"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:orientation="vertical" >

    <TableRow
        android:id="@+id/tableRow00"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="right|top"
        android:gravity="right" >

        <Button
            android:id="@+id/id_but_val"
            android:layout_width="@dimen/button_width"
            android:layout_height="wrap_content"
            android:background="@drawable/button_colored"
            android:text="@string/but_valid"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <Button
            android:id="@+id/id_but_up"
            android:layout_width="@dimen/button_width"
            android:layout_height="wrap_content"
            android:background="@drawable/button_colored"
            android:onClick="goToTop"
            android:text="@string/but_ret_up"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <Button
            android:id="@+id/id_but_back"
            android:layout_width="@dimen/button_width"
            android:layout_height="wrap_content"
            android:background="@drawable/button_colored"
            android:text="@string/but_ret_back"
            android:textAppearance="?android:attr/textAppearanceMedium" />
    </TableRow>

    <ScrollView
        android:id="@+id/ScrollView01"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:isScrollContainer="true"
        android:overScrollMode="always"
        android:scrollbarAlwaysDrawVerticalTrack="true"
        android:scrollbarStyle="outsideInset" >

        <LinearLayout
            android:id="@+id/LinearLayout01"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:orientation="vertical" >

            <TableRow
                android:id="@+id/TableRow01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/row_margin_top" >

                <TextView
                    android:id="@+id/TextView01"
                    android:layout_width="@dimen/label_width"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:text="@string/ecran3_84_obstacles_acces" />

                <RadioGroup
                    android:id="@+id/RadioGroup01"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:orientation="horizontal" >

                    <RadioButton
                        android:id="@+id/RadioButton01"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/radio_value_oui" />

                    <RadioButton
                        android:id="@+id/RadioButton02"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/radio_value_non" />
                </RadioGroup>
            </TableRow>

            <TableRow
                android:id="@+id/TableRow02"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/row_margin_top" >

                <TextView
                    android:id="@+id/TextView02"
                    android:layout_width="@dimen/label_width"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:text="@string/ecran3_85_limit_tonnage" />

                <EditText
                    android:id="@+id/EditText01"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:ems="@string/editTextEms"
                    android:inputType="numberDecimal" />
            </TableRow>

            <TableRow
                android:id="@+id/TableRow03"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/row_margin_top"
                android:visibility="gone" >

                <TextView
                    android:id="@+id/TextView03"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:text="@string/ecran3_86_derog" />
            </TableRow>

            <TableRow
                android:id="@+id/TableRow04"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/row_margin_top" >

                <TextView
                    android:id="@+id/TextView04"
                    android:layout_width="@dimen/label_width"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:text="@string/ecran3_87_limit_hauteur" />

                <EditText
                    android:id="@+id/EditText03"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:ems="@string/editTextEms"
                    android:inputType="numberDecimal" />
            </TableRow>

            <TableRow
                android:id="@+id/TableRow05"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/row_margin_top" >

                <TextView
                    android:id="@+id/TextView05"
                    android:layout_width="@dimen/label_width"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:text="@string/ecran3_88_limit_largeur" />

                <EditText
                    android:id="@+id/EditText04"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:ems="@string/editTextEms"
                    android:inputType="numberDecimal" />
            </TableRow>

            <TableRow
                android:id="@+id/TableRow06"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/row_margin_top" >

                <TextView
                    android:id="@+id/TextView06"
                    android:layout_width="@dimen/label_width"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:text="@string/ecran3_89_trav_jour" />

                <RadioGroup
                    android:id="@+id/RadioGroup06"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:orientation="horizontal" >

                    <RadioButton
                        android:id="@+id/RadioButton11"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/radio_value_oui" />

                    <RadioButton
                        android:id="@+id/RadioButton12"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/radio_value_non" />
                </RadioGroup>
            </TableRow>

            <TableRow
                android:id="@+id/TableRow07"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/row_margin_top" >

                <TextView
                    android:id="@+id/TextView07"
                    android:layout_width="@dimen/label_width"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:text="@string/ecran3_90_acces_intemperies" />

                <RadioGroup
                    android:id="@+id/RadioGroup07"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:orientation="horizontal" >

                    <RadioButton
                        android:id="@+id/RadioButton13"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/radio_value_oui" />

                    <RadioButton
                        android:id="@+id/RadioButton14"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/radio_value_non" />
                </RadioGroup>
            </TableRow>

            <TableRow
                android:id="@+id/TableRow08"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/row_margin_top" >

                <TextView
                    android:id="@+id/TextView08"
                    android:layout_width="@dimen/label_width"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:text="@string/ecran3_91_acces_de_client" />

                <RadioGroup
                    android:id="@+id/RadioGroup08"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/view_left_margin"
                    android:orientation="horizontal" >

                    <RadioButton
                        android:id="@+id/RadioButton15"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/radio_value_oui" />

                    <RadioButton
                        android:id="@+id/RadioButton16"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/radio_value_non" />
                </RadioGroup>
            </TableRow>

            <LinearLayout
                android:id="@+id/LinearLayout02"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <TableRow
                    android:id="@+id/TableRow09"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/row_margin_top" >

                    <TextView
                        android:id="@+id/TextView09"
                        android:layout_width="@dimen/label_width"
                        android:layout_height="fill_parent"
                        android:layout_marginLeft="@dimen/view_left_margin"
                        android:text="@string/ecran3_92_contraintes_reservoir" />

                    <EditText
                        android:id="@+id/EditText05"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/view_left_margin"
                        android:ems="@string/editTextEms"
                        android:inputType="text" />
                </TableRow>

                <TableRow
                    android:id="@+id/TableRow10"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/row_margin_top" >

                    <TextView
                        android:id="@+id/TextView10"
                        android:layout_width="@dimen/label_width"
                        android:layout_height="fill_parent"
                        android:layout_marginLeft="@dimen/view_left_margin"
                        android:text="@string/ecran3_93_dalle_pret" />

                    <RadioGroup
                        android:id="@+id/RadioGroup10"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/view_left_margin"
                        android:orientation="horizontal" >

                        <RadioButton
                            android:id="@+id/RadioButton19"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/radio_value_oui" />

                        <RadioButton
                            android:id="@+id/RadioButton20"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/radio_value_non" />
                    </RadioGroup>
                </TableRow>
<!-- TableRow10 to TableRow26 -->
            </LinearLayout>
        </LinearLayout>
    </ScrollView>

</LinearLayout>
4

1 に答える 1

2

完全なレイアウトが表示されない場合は、それTableLayoutListView. にViews切り替えると、レイアウト全体をメモリにロードする必要がなくなり、代わりに+ 任意のビューListViewの画面に表示されている行のみがロードされます。ListViewあなたはそれ以外にも持っています。

上記のアプローチを使用すると、現在のレイアウトからかなりの数の行を削除できます。

編集 :

追加したレイアウトに基づいて、いくつかのアドバイス:

  • TableRowレイアウトで通常のビューとして使用できますが、主な目的は の子にすることTableLayoutです。
  • Buttonsfromを同じ幅にしたくない場合tableRow00は、現在のレイアウトを少し改善して、 に置き換えLinearLayout00RelativeLayoutを削除してから、 のルールを使用してとをtableRow00配置します。ButtonsScrollViewRelativeLayout
  • に置き換えLinearLayout01ますTableLayout
  • を追加した理由はわかりませんがLinearLayout02(すべての行が同じだと思いますか?!)、それを削除して直接追加する必要がありますTableRow09- TableRow26to LinearLayout01
  • 私の答えの残りは残っています。
于 2012-04-25T10:17:20.863 に答える