2011-12-26 2 views
0

두 개의 텍스트 뷰를 가로로 가운데에 놓으려고하므로 화면 상단에 서로 나란히 있습니다. TextViews 중 하나가 다른 것보다 크기 때문에이 작업을 수행하고 있습니다. 여기 내 코드입니다어떻게 안드로이드를 중심으로합니까?

<TableRow 
    android:layout_gravity="center"> 

    <TextView 
     android:layout_column="1" 
     android:padding="3dip" 
     android:gravity="right" 
     android:text="open" /> 

    <TextView 
     android:padding="3dip" 
     android:gravity="left" 
     android:text="Ctrl O" /> 
</TableRow> 

답변

0

꽤 귀하의 질문에 비트가 못해서이 당신을 위해 무엇을 찾고 :

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/tableLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <TableRow 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_column="1" 
     android:gravity="center" > 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="right" 
      android:padding="3dip" 
      android:text="open" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="left" 
      android:padding="3dip" 
      android:text="Ctrl O" /> 
    </TableRow> 

</TableLayout> 
+0

나는 분명치 않다. 나는 화면의 첫 번째 줄에 두 개의 텍스트를 수평으로 배치하는 것을 의미했습니다. – Aaron

+0

TableLayout을 추가하면 ... 편집을 참조하십시오. – RonzyFonzy

0

그래서 당신이 서로 옆의 중심에 귀하의 의견을 원한다 이런 화면?

| View1|reallylongView2 | 

일반적으로 테이블을 갖고 싶지 않으면 일반적으로 테이블 행을 피하십시오. 위의 내용을 원한다면 가장 좋은 방법은 단일 텍스트보기를 사용하는 것입니다. 특히 앱을 국제화하는 경우 텍스트의 순서를 변경해야 할 수도 있습니다.

그렇지 차례로과 같이 텍스트 뷰가 모두 포함 된 중심의 수평 선형 레이아웃 아이로, 상대 레이아웃 부모를 시도 :
<RelativeLayout 
    ... 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:orientation="horizontal" > 
     <TextView ... /> 
     <TextView ... /> 
    </LinearLayout> 
</RelativeLayout> 

그렇지 않으면 당신은 당신이 무엇을 찾고 있는지 명확히 할 필요가있다. 스크린 샷이나 아스키 아트가 도움이 될 것입니다.

관련 문제