2011-01-27 2 views
3

나는리스트 뷰의 토대가되는 다음 코드를 가지고있다.tablerow의 체크 박스가 텍스트 뷰로 화면에서 밀려났다

아이디어는 항상 화면의 오른쪽에 정렬되는 확인란을 갖는 것입니다. 그것의 왼쪽에있는 텍스트가 너무 길면 나는 그것을 줄여서 "..."표시하거나 우아하게 잘라 버리고 싶습니다.

텍스트는 짧지 만 텍스트가 길면 정상적으로 작동합니다. 어떤 충고?

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

<TableLayout android:id="@+id/TableLayout01" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:stretchColumns="0" 
> 

    <TableRow 
     android:id="@+id/TableRow01" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
    > 

     <TextView android:id="@+id/name" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dip" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="This is a very very long title 12345678"  
     /> 

     <CheckBox android:id="@+id/checkbox" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"   
     /> 

    </TableRow> 
</TableLayout> 

</LinearLayout> 

답변

1

하지 0dip 및 안드로이드 사용하는 당신은 TableRow를 사용하고 있지만 선형 레이아웃의 텍스트 뷰와 체크 박스 포장의 더 나은 및 layout_width 설정하는 이유도 확인하십시오 텍스트 뷰와 양의 비율을 설정하는 데에 layout_weight를 확인란.

예 : 잘 작동하는 것 같다

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent"> 
    <TextView android:id="@+id/TextView01" android:layout_height="wrap_content" 
     android:layout_width="0dip" android:layout_weight="3" android:text="TextView"></TextView> 
    <CheckBox android:id="@+id/CheckBox01" android:layout_height="wrap_content" 
     android:layout_width="0dip" android:layout_weight="1"></CheckBox> 
</LinearLayout> 
+0

감사합니다. 제가 테이블 레이아웃을 사용하는 이유는 제가 정말로하고 싶었던 것은 바로 정렬 된 체크 박스가있는리스트를 가지고 있기 때문입니다. 그리고 나서 구글은이 예제로 나를 이끌었습니다 : http://huuah.com/using-tablelayout-on-android/ 내가 권장하는대로 작동하지만 텍스트는 다음 줄에서 잘립니다. 지금은별로 중요하지 않습니다. 목록에 하나 이상의 항목이 있어야하기 때문에이 예제에 표시하기가 어렵습니다 ... –

관련 문제