2014-06-17 43 views
0

在添加@ + id/secondLayout之前,一切都顯示正常。突然,在添加它之後,桌面佈局不再顯示。 任何想法?在Android中添加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="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> 

在此先感謝您的時間。

+0

和什麼是天文鐘? –

+0

@Rod_Algonquin它是一個Android小部件來顯示一個天文臺... http://developer.android.com/reference/android/widget/Chronometer.html – iversoncru

+0

我認爲你有一個重複的ID ..確保它是獨特的.. –

回答

0

使用LinearLayoutTableLayout高度"wrap_content",因爲孩子LinearLayout了家長的空間layout.so 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> 
0

android:layout_below="@id/chrono"具有LinearLayout因爲它是在使用RelativeLayout沒有影響。 給體重您TableLayout爲1,改變你的android:layout_height"wrap_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> 
0

試圖改變天文臺高度WRAP_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="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> 
相關問題