2013-10-22 4 views
1

테이블 레이아웃에 약간의 문제가 있습니다.TableLayout은 한 줄에 텍스트를 적용합니다.

두 개의 열이 있습니다.

column1 | 제 2 열

칼럼 1의 내용은 정적이며 속성을 나타낸다. "위치", "제품". 두 번째 열은 어댑터를 사용하여 채워집니다.

제 문제는 텍스트보기가 column1의 단어를 분리한다는 것입니다. 나는 column1의 단어를 정확히 한 행에 표시하고 싶습니다 (행이 끊어지지 않도록하십시오). 그리고 두 번째 컬럼의 크기는 적응해야합니다.

나는 또한에 layout_weight를 설정하려고 만일 Singleline = "true"를 장치 (S3)는 단지 보여줍니다 그러나 처음 몇 글자와 ... :

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/tl" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_margin="5dp" 
    android:shrinkColumns="*" 
    android:stretchColumns="*" 

    > 


    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="5dp"> 

      <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="products" 
      android:padding="5dp" 

      /> 

     <TextView 
      android:id="@+id/newID" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 
      android:text="Branche" 
      android:padding="5dp"/> 


    </TableRow> 
</TableLayout> 

나는 안드로이드를 설정했습니다. 그러나 나는이 문제를 해결할 수 없었다. 당신의 도움에 대한

감사

답변

1

이 코드를보십시오 : 당신이 layout_weight 속성을 사용하는 경우

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/tl" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_margin="5dp" 
android:shrinkColumns="*" 
android:stretchColumns="*"> 


<TableRow 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:padding="5dp"> 

    <TextView 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.3" 
     android:text="products" 
     android:padding="5dp"/> 

    <TextView 
     android:id="@+id/newID" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.7" 
     android:text="ancheBrrancheBraeBrancheBrancheBrancheBrancheBrancheBrancheBrancheBrancheBranche" 
     android:padding="5dp"/> 

</TableRow> 
</TableLayout> 

, 당신은 layout_width0dp로 설정해야한다는 사실에 대해 remeber한다 (물론이 경우에는) .

관련 문제