2012-07-03 5 views
-1

2 행 3 열 테이블 레이아웃을 만들고 싶습니다. 첫 번째 행에 3 개의 TextView를 추가하고 두 번째 행에 하나의 버튼을 3 개의 열에 추가하고 싶습니다.Android TableLayout에서 확장 가능한 TextView를 만드는 방법은 무엇입니까?

각 텍스트보기는 다른 클릭 동작의 텍스트로 채워져 있으므로 100 개의 문자가 포함될 수 있으며 문자가 포함되지 않을 수도 있습니다 첫 번째 문자에는 문자가 있고 다른 문자에는 문자가없는 경우 첫 번째 문자는 확장되어야합니다. 모든 공간,하지만 두 개의 텍스트가 들어있는 경우, 두 빈 공간을 채우기 위해 확장해야합니다

누가 나를 도울 수 있습니까? 이 내 코드는하지만,이 코드는 세에 테이블이 컬럼

<TableLayout 
     android:id="@+id/temps_holder" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/google_adView" 
     android:background="@drawable/round" 
     android:gravity="right"   
     android:stretchColumns="0" > 

     <TableRow> 

      <TextView 
       android:id="@+id/time_temp" 
       android:layout_width="0dp" 
       android:layout_height="fill_parent" 
       android:layout_marginLeft="3dp" 
       android:layout_marginRight="3dp" 
       android:layout_weight=".33" 
       android:gravity="center" 
       android:singleLine="false" 
       android:text="" 
       android:textColor="@color/White" 
       android:textSize="16sp" /> 

      <TextView 
       android:id="@+id/tempText2_TextView" 
       android:layout_width="0dp" 
       android:layout_height="fill_parent" 
       android:layout_weight=".33" 
       android:gravity="center" 
       android:singleLine="false" 
       android:text="" 
       android:textColor="@color/White" 
       android:textSize="16sp" /> 

      <TextView 
       android:id="@+id/tempText1_TextView" 
       android:layout_width="0dp" 
       android:layout_height="fill_parent" 
       android:layout_weight=".33" 
       android:gravity="center" 
       android:singleLine="false" 
       android:text="" 
       android:textColor="@color/White" 
       android:textSize="16sp" /> 
     </TableRow> 

     <TableRow> 

      <Button 
       android:id="@+id/viewMatched_btn" 
       android:layout_width="fill_parent" 
       android:layout_height="40dp"     
       android:layout_span="3" 
       android:background="@drawable/wood_btn" 
       android:onClick="viewResults" 
       android:text="@string/viewMatched" 
       android:textColor="@color/White" 
       android:visibility="invisible" /> 
     </TableRow> 
    </TableLayout> 

답변

0

이 당신이 후에 무엇인가를 동일 올바른하지, 그것을 제산 무엇입니까?

<TableRow> 

     <Button 
      android:id="@+id/viewMatched_btn" 
      android:layout_width="fill_parent" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Button"    
      android:onClick="viewResults"    
      android:visibility="visible" /> 
    </TableRow> 
</TableLayout> 

변경 버튼 속성 : android:visibilityvisible 및 추가

android:layout_width="wrap_content" android:layout_height="wrap_content"

enter image description here

enter image description here

enter image description here

+0

이 소스 코드는 큰 파일의 코드 하위에 있습니다. 원래 파일에 xmlns를 사용했습니다. –

+0

O 죄송합니다. 나는 나의 대답을 업데이트 할 것이다. – 0gravity

+0

각 텍스트 뷰에 대해 100 자 이상으로 테스트 했습니까? –

관련 문제