2012-08-03 3 views
2

내 안드로이드 응용 프로그램에 대한 사용자 정의 TableRow를 만들고 싶습니다. LinearLayout에서 시작했는데 정확하게 표시하고 싶지만 TableLayout의 TableRow로 표시합니다.TableRow 내부의 LinearLayout이 경고를 내림

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:padding="10dp" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:paddingBottom="3dp" 
     android:paddingTop="3dp" 
     android:weightSum="1" > 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.7" 
      android:text="@string/Context" /> 

     <TextView 
      android:id="@+id/ContextTextView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.3" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:paddingBottom="3dp" 
     android:paddingTop="3dp" 
     android:weightSum="1" > 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.7" 
      android:text="@string/SHUId" /> 

     <TextView 
      android:id="@+id/SHUIdTextView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.3" /> 
    </LinearLayout> 

    ...Others LinearLayouts with 2 TextViews... 

</LinearLayout> 

그래서 먼저 내가 TableRow 요소 내에이 코드를 넣어 시도 : 레이아웃은 일식 편집기에서 제대로 표시이 시점에서

<TableRow xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    ...LinearLayout code from above... 

<TableRow /> 

하지만 지금은 주요있는 LinearLayout에 린트 경고를 : "이 LinearLayout 레이아웃이나 그 TableRow 부모는 쓸모가 없다"

그럼 내가 좋아하는 TableRow LinearLayout의 하위 클래스입니다 그리고 난 단순히 주 LinearLayout을 제거하고 TableRow에서 직접 자신의 속성을 넣어 수 :

<TableRow xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:padding="10dp" > 

    <LinearLayout > 
     <TextView /> 
     <TextView /> 
    <LinearLayout /> 

    <LinearLayout > 
     <TextView /> 
     <TextView /> 
    <LinearLayout /> 

    ...etc... 

<TableRow /> 

하지만 이제 레이아웃이 올바르게 표시되지 않지만 경고는 표시되지 않습니다. 첫 번째 줄만 보았습니다 (두 번째 첫 번째 TextView 포함). 내가 무엇이 누락 되었습니까?

답변

1

TableRow의 어린이는 TableLayout입니까? 그렇지 않다면 TableRow을 사용하지 않아야합니다. TableLayout이 없으면 가로가 LinearLayout이 아닙니다.

+0

TableRayout에 프로그래밍 방식으로 TableRow를 추가하지만 XML 파일에 TableRow가 하나만 있습니다. – Alexis

+0

가로형 LinearLayout 인 경우 android : orientation = "vertical"속성이 고려되지 않았습니까? – Alexis

+0

글쎄, 당신은 당신의 대답을 가지고, TableRow는 수평 LinearLayout이고 가장 가까운 LinearLayout은 수직입니다 - 당신이 그것을 제거하면 수평 TableRow 오른쪽에 있기 때문에 두 번째 행을 볼 수 없습니다. 가장 외적인 LinearLayout을 떠나 경고를 무시하십시오. –