Das Attribut layout_weight in der letzten Textansicht in diesem Layout wird von Lint als schlechte Leistung hervorgehoben. Ich vermute, dass der Name der Fusselwarnung falsch ist, da es keine verschachtelten Gewichte gibt. Es gibt mehrere Dehnungsansichten, und ich vermute, was es bedeutet, sind abhängige gewichtete Ansichten.Warum zeigt Android Lint "verschachtelte Gewichte sind schlecht für die Leistung", wenn keine verschachtelt sind?
Was ist die Lösung, um dieses Layout zu erstellen und diese Flusenwarnung zu vermeiden und die Leistung zu verbessern?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:background="@drawable/background_gradient"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image4"
android:layout_margin="6dp"
android:contentDescription="@string/PLACEHOLDER_TEXT"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<Button
style="@style/dashboard_button"
android:id="@+id/home_management"
android:text="@string/ICON_MANAGEMENT"
/>
<Button
style="@style/dashboard_button"
android:id="@+id/home_calculators"
android:text="@string/ICON_CALCULATORS"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<Button
style="@style/dashboard_button"
android:id="@+id/home_guidelines"
android:text="@string/ICON_GUIDELINES"
/>
<Button
style="@style/dashboard_button"
android:id="@+id/home_faq"
android:text="@string/ICON_FAQ"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
>
<Button
style="@style/dashboard_button"
android:id="@+id/home_refs"
android:text="@string/ICON_REFERENCES"
/>
<Button
style="@style/dashboard_button"
android:text=""
android:visibility="invisible"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_margin="6dp"
>
<TextView
android:text="@string/HOMEPAGE_CONTENT"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textStyle="bold"
android:textColor="#FFFFFF"
/>
<View
android:layout_width="8dp"
android:layout_height="1dp"
/>
<ImageView
android:id="@+id/home_logo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/image7"
android:contentDescription="@string/PLACEHOLDER_TEXT"
/>
</LinearLayout>
<Button
android:id="@+id/home_web_site"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/HOMEPAGE_FOOTER"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:textSize="12sp"
android:background="@drawable/button_red"
android:layout_margin="6dp"
android:textColor="#FFFFFF"
/>
</LinearLayout>
Siehe auch: http://stackoverflow.com/questions/9430764/why-are-nested-weights-bad-for-performance-alternatives –