2013-01-16 6 views
0

dashboardNewsItemDate을 왼쪽이 아닌 오른쪽으로 정렬하는 방법을 알아 내려고합니다. 현재는 dashboardNewsItemHeadline 옆에 즉시 나타납니다. TableRow 안에 넣으면 android:layout_gravity="right" 기능을 원하는대로 작동시킬 수 있다고 생각했지만 잘못된 것으로 입증되었습니다. 결국 텍스트를 오른쪽으로 정렬하는 방법

<TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:layout_gravity="center"> 
    <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 
     <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="New Text" 
       android:id="@+id/dashboardNewsItemHeadline" android:layout_gravity="left" 
       /> 
     <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="New Text" 
       android:id="@+id/dashboardNewsItemDate" android:layout_gravity="right" android:autoText="false"/> 
    </TableRow> 
</TableLayout> 

, 내 목표는 대신

My news title      Mar 3 
----------------------------------------- 
This is a bit of a longer news  Jul 2 
title and it wraps 

답변

0

당신은 가까이, 일반적인 "중력"을 시도 ... 그래서 다음과 같이 표시 될 내용입니다 TextViews에 대한 "layout_gravity".

+0

작동하지 않았다 : - \ – Webnet

0

마지막 TextView의 layout_width="wrap_content"gravity="right"을 취소하고 있습니다. fill_parent 또는 match_parent으로 변경하면 제대로 작동합니다.

0

문제 해결해야 마법의 속성이 있습니다 :

android:stretchColumns="*" 

가이 속성을 추가하여 TableLayout :

불행하게도
<TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_gravity="center" 
     android:stretchColumns="*"> 
    <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 
     <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="New Text" 
       android:id="@+id/dashboardNewsItemHeadline" android:layout_gravity="left" 
       /> 
     <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="New Text" 
       android:id="@+id/dashboardNewsItemDate" android:layout_gravity="right" android:autoText="false"/> 
    </TableRow> 
</TableLayout> 
관련 문제