2012-01-18 53 views
3

我都內的LinearLayout tablelayout解決,但它讓我看到這個警告信息
這TableLayout佈局或它的LinearLayout父母也沒用 如何克服這個警告可能ANE幫我 。 在此先感謝這TableLayout佈局或它的LinearLayout父母也沒用如何從這個警告

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

      <TableLayout> 

      <TableRow 
       android:id="@+id/tableRow3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" > 

       <TextView 
        android:id="@+id/txtPass" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical|center_horizontal" 
        android:text="Password" 
        android:textSize="18sp" 
        android:width="100dp" /> 

       <EditText 
        android:id="@+id/edPass" 
        android:layout_width="200dp" 
        android:layout_height="wrap_content" 
        android:inputType="textPassword" 
        android:password="true" > 

        <requestFocus /> 
       </EditText> 
       </TableRow> 
      </TableLayout> 

     </LinearLayout> 

回答

7

爲什麼你需要最頂端的LinearLayout當你沒有內部的LinearLayout任何東西,除了TableLayout?其中一種佈局應該足夠了。除去LinearLayout(或)TableLayout。這應該可以解決問題。

+0

現在我有這個佈局<?xml version =「1.0」encoding =「utf-8」?> <的TableRow 機器人:ID = 「@ + ID/tableRow1」 機器人:layout_width = 「WRAP_CONTENT」 機器人:layout_height = 「WRAP_CONTENT」 > 裏面 2012-01-18 05:59:42

+0

這應該工作。你還在收到那個警告信息嗎? – kosa 2012-01-18 06:03:32

+0

是一樣的警告再次 – 2012-01-18 06:05:03

0

如果下面正在尋找佈局則XML如下

Password_layout

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:gravity="center"> 
<TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Password" /> 
<EditText 
     android:layout_marginLeft="5dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:hint="Password" /> 


</LinearLayout> 
1

通過報警,該系統只是想說你有空間,優化佈局code.There如果您現在不想優化您的代碼,則無需關心它。

+0

不過,注意警告是個好習慣 - 他們通常有一個要點!在這種情況下,兩個佈局都是不必要的,所以應該刪除一個佈局。 – 2012-04-12 20:32:13

1

刪除TableLayout標記並將屬性放入TableRow標記中。