我在绘制嵌套的线性布局时遇到问题。在第二个线性布局(第一个包含在主线性布局中)之后,没有其他任何显示!但我的 xml 文件中没有任何错误消息。
---main linearLayout--------------------------------
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
tools:context=".MainActivity"
>
------first included linearLayout: it's shown without nay problems--------------------
<LinearLayout
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="@string/hello_world" />
</LinearLayout>
------second included linearLayout: it's NOT shown--------------------
<LinearLayout
android:background="#CCCCCC"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:gravity="center"
android:weightSum="1">
<ImageView
android:layout_width="0dp"
android:layout_weight="0.3"
android:layout_marginLeft="2dp"
android:background="@drawable/ic_launcher"
android:layout_height="100dp"/>
</LinearLayout>
</LinearLayout>