android.view.InflateException: Binary XML file line #1: Error inflating class Linearlayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.Linearlayout"
Android XML 布局中標籤名區分大小寫,必須與類名完全一致。
正確:<LinearLayout>(L 大寫)
錯誤:<Linearlayout>(l 小寫)
<LinearLayout xmlns:android="https://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/left"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#CCCCCC"
android:orientation="vertical">
<Button ... />
</LinearLayout>
<LinearLayout
android:id="@+id/center"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#CCDDFF"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:id="@+id/right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#CCFFDD"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
layout_weight 分配寬度,而非寫死 0dp 且無權重。ConstraintLayout 扁平化。