2015-07-04 43 views
-1

我試圖讓一個接口,使水平文本,以同樣的空間,使用layout_weight爲響應layout_weight:文本不顯示

所以,我想下面

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:gravity="center_vertical" 
android:background="@android:color/darker_gray"> 

<TextView 
    android:gravity="center" 
    android:text="Guest List" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:textSize="24sp" 
    android:background="@android:color/holo_blue_bright"/> 

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="horizontal" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="@android:color/white"> 
    <TextView 
     android:text="Kunal" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:textSize="24sp"/> 


    <TextView 
     android:text="Darling" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:textSize="24sp"/> 

    <TextView 
     android:text="Shocker" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:textSize="24sp"/> 
</LinearLayout> 

代碼

但是,所有的文字都消失了。 那麼,有誰可以請向我解釋發生了什麼事以及如何解決這個問題?

+0

** ** 1 - 格式化你的代碼。 ** 2 ** - 您是否關閉了外部LinearLayout? ** 3 ** - 如何填充TextViews?我看不到其中的文字。 –

+0

** 4 ** - 您可以通過使用RelativeLayout來避免「佈局嵌套」(對性能不利)。 **更容易**的方式並不總是**首選**。 –

回答

1

試試這個,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/darker_gray" 
    android:gravity="center_vertical" 
    android:orientation="vertical" > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/holo_blue_bright" 
     android:gravity="center" 
     android:text="Guest List" 
     android:textSize="24sp" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/white" 
     android:orientation="horizontal" > 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Kunal" 
      android:textSize="24sp" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Darling" 
      android:textSize="24sp" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Shocker" 
      android:textSize="24sp" /> 
    </LinearLayout> 

</LinearLayout> 
0

使用在第二的LinearLayout一個白色的背景顏色,你可能會想看看白色白色文字。

我會嘗試添加到TextViews沿東西:

 android:textColor="@android:color/black"