在Android中添加LinearLayout后未显示TableLayout

在Android中添加LinearLayout后未显示TableLayout,android,android-linearlayout,add,tablelayout,Android,Android Linearlayout,Add,Tablelayout,在我添加@+id/secondLayout之前,一切都正常。突然,在添加它之后,tablelayout不再显示。 有什么想法吗 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/firstLayout" android:layout_width="match_parent

在我添加@+id/secondLayout之前,一切都正常。突然,在添加它之后,tablelayout不再显示。 有什么想法吗

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout 
android:id="@+id/secondLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
    <Chronometer
    android:id="@+id/chrono"
    android:textColor="#4169E1"
    android:textSize="20sp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Chronometer"
    />
</LinearLayout>
<TableLayout 
    android:id="@+id/parentLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/chrono"
>

</TableLayout>
</LinearLayout>


提前感谢您的时间。

使用
LinearLayout
TableLayout
高度来
“包装内容”
,因为子
LinearLayout
占用了父布局的空间。因此
TableLayout
不显示。
即尝试此布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout 
android:id="@+id/secondLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
    <Chronometer
    android:id="@+id/chrono"
    android:textColor="#4169E1"
    android:textSize="20sp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Chronometer"
    />
</LinearLayout>
<TableLayout 
    android:id="@+id/parentLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
>

</TableLayout>
</LinearLayout>

android:layout_lower=“@id/chrono”在
线性布局中无效,因为它在
相对布局中使用。
将您的
TableLayout
的权重设为1,并将您的
android:layout\u height
更改为
“wrap\u content”
请尝试以下数据:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/firstLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/secondLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        >

        <Chronometer
            android:id="@+id/chrono"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Chronometer"
            android:textColor="#4169E1"
            android:textSize="20sp" />
    </LinearLayout>

    <TableLayout
        android:id="@+id/parentLayout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="#123456"
        android:layout_weight="1" >
    </TableLayout>

</LinearLayout>

尝试更改计时器的高度以包裹内容物

尝试使用

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/firstLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/secondLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Chronometer
            android:id="@+id/chrono"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Chronometer"
            android:textColor="#4169E1"
            android:textSize="20sp" />
    </LinearLayout>

    <TableLayout
        android:id="@+id/parentLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/chrono" >
    </TableLayout>

</LinearLayout>


什么是天文钟?@Rod_Algonquin它是一个Android小部件,用于显示天文钟。。。我想你的身份证是重复的。。确保它是独一无二的。。