2012-05-25 5 views
2

나는 두 번째 셀의 값 (배경 이미지가있는 단추)이 첫 번째 셀의 텍스트 오른쪽에 오도록 아래 테이블 행에 셀을 배열하려고했습니다. 아래는 현재 셀 2의 이미지를 늘리고 this처럼 보입니다.TableLayout 셀 위치 지정

스트레치를 멈추고 버튼 이미지를 셀 2의 맨 왼쪽에 배치하는 방법에 대한 아이디어가 있습니까?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <TableLayout 
     android:layout_width="fill_parent" 
     android:layout_weight="1" 
     android:layout_height="wrap_content" 
     android:stretchColumns="1" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp"> 
     <TableRow> 
     <TextView 
      android:id="@+id/timeMainLabel" 
      android:layout_weight="1" 
      android:textSize="14sp" 
      android:layout_column="0" 
      android:padding="1dip" 
      android:text="cell one texxxxxxxxt"/> 
     <Button 
      android:id="@+id/pdm_tooltip_btn1" 
      android:layout_column="1" 
      android:background="@drawable/tooltip_btn" /> 
     <TextView 
      android:layout_column="2" 
      android:id="@+id/timeLabel" 
      android:textSize="14sp" 
      android:text="cell 3" 
      android:gravity="right" 
      android:padding="1dip" 
      android:visibility="visible" 
      android:layout_weight="1"/> 
    </TableRow> 
    <TableRow> 
     <TextView 
      android:id="@+id/timeMainLabel" 
      android:layout_weight="1" 
      android:textSize="14sp" 
      android:layout_column="0" 
      android:padding="1dip" 
      android:text="cell one text"/> 
     <Button 
      android:id="@+id/pdm_tooltip_btn1" 
      android:layout_column="1" 
      android:background="@drawable/tooltip_btn" /> 
     <TextView 
      android:layout_column="2" 
      android:id="@+id/timeLabel" 
      android:textSize="14sp" 
      android:text="cell 3" 
      android:gravity="right" 
      android:padding="1dip" 
      android:visibility="visible" 
      android:layout_weight="1"/> 
    </TableRow> 
    </TableLayout> 
</LinearLayout> 

업데이트 이미지 : enter image description here

+0

아래의 설명을 참조하십시오. – c12

답변

3

는거야 일부 손보는 주위가 필요합니다. 기본적으로, 컬럼 1 이후에 빈 컬럼을 추가해야합니다 (인덱스가 0이므로 두 번째 컬럼이됩니다).

그래서 당신은해야합니다 : 당신은 공상과 적절하게 설정 한 경우
<TableRow> 
    <TextView layout_column="0"> 

    <Button layout_column="1"> 

    <TextView layout_column="2"> // DUMMY! 

    <TextView layout_column="3"> 
</TableRow> 

지금 당신이 weight 바이올린 수 있습니다.

세 번째 열 (두 번째 열)은 두 요소 사이의 공간을 채워서 필요한 경우 늘어납니다.

+0

응답 해 주셔서 감사합니다. 이미지 열을 밀어 넣을 특정 너비의 더미 텍스트 뷰를 넣었지만 "보낸 메시지 수"열의 텍스트 바로 옆에서 가져올 수 없습니다 (업데이트 된 이미지 참조). 그 셀이 가장 긴 텍스트의 길이까지 늘어나는 것 같습니다. 메시지를 전송 한 메시지 내부에서 이미지를 이동할 방법이 있습니까? – c12

+0

모두가 다른 TableRow 요소에 있으면 다른 셀의 너비에는 영향을주지 않습니다. 한 행이 어떤 식 으로든 다른 행의 열에 영향을 미치지 않으므로이 동작은 설명 할 수 없습니다. – ScarletAmaranth

+0

나는이 질문을 편집하여이 답변을 편집 할 수 있도록 도와 주므로 같은 것을 검색하려는 사람과 관련 될 수 있습니다. 귀하의 질문은 아마 내게 의미가 있습니다 :-) 아니면 그냥 새로운 질문이나 뭔가를 던져. – ScarletAmaranth