我在Android Studio中的布局上收到此警告:
嵌套权重不利于性能降低...
布局权重要求 一个要两次测量的小部件。当LinearLayout具有非零值时 权重嵌套在另一个具有非零权重的LinearLayout中, 然后测量的数量呈指数增长。
问题ID: NestedWeights
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
style="?android:attr/buttonBarStyle">
<Button
android:id="@+id/b1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#093A3E"
android:foreground="?attr/selectableItemBackground"
android:text="One"
android:textAllCaps="false"
android:textColor="#fff"
android:textSize="18sp"
style="?android:attr/buttonBarButtonStyle" />
<Button
android:id="@+id/b2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#3AAFB9"
android:foreground="?attr/selectableItemBackground"
android:text="Two"
android:textAllCaps="false"
android:textColor="#fff"
android:textSize="18sp"
style="?android:attr/buttonBarButtonStyle" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
style="?android:attr/buttonBarStyle">
<Button
android:id="@+id/b6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:foreground="?attr/selectableItemBackground"
android:layout_weight="1"
android:background="#64E9EE"
android:text="Three"
android:textAllCaps="false"
android:textColor="#fff"
android:textSize="18sp"
style="?android:attr/buttonBarButtonStyle" />
<Button
android:id="@+id/b7"
android:layout_width="0dp"
android:layout_height="match_parent"
android:foreground="?attr/selectableItemBackground"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#97C8EB"
android:text="Four"
android:textAllCaps="false"
android:textColor="#fff"
android:textSize="18sp"
style="?android:attr/buttonBarButtonStyle" />
</LinearLayout>
</LinearLayout>
如何避免出现此警告并获得相同的结果?谢谢。