我試圖在LinearLayout中分配權重。 雖然它與ButtonView-S的作品,它只是可以用於簡單查看相反:android:layout_weight for view的行爲與預期相反
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#FF0000" />
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:background="#00FF00" />
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="#0000FF" />
</LinearLayout>
和
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#FF0000" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:background="#00FF00" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="#0000FF" />
</LinearLayout>
這是deffinetly實現ButtonView的那使其正常工作。 但是應該在View中實現(以及如何)與LinearLayout行爲一致? 非常感謝。
對於兩者都是相同的輸出,重新檢查。 –
對我來說也是一樣的輸出。 –
是的,確實如此 - 我的自定義視圖錯誤( –