2010-12-06 4 views
0

저는 안드로이드에 비교적 익숙하며,이 레이아웃을 수행하는 더 좋은 방법이 있는지 궁금합니다. 왼쪽에 세로로 쌓인 네 개의 레이블이 필요합니다. 오른쪽에는 큰 글꼴 두 개의 레이블이 필요합니다. 에뮬레이터에서이 코드를 실행하면 정확하게 필요한 부분이 있지만 더 선호되는 방법이 있습니까?Android -이 레이아웃을 수행하는 더 좋은 방법이 있습니까?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 
    <TextView 
     android:id="@+id/Label1" 
     android:text="Label 1: " 
     android:layout_width="200dp" 
     android:layout_height="wrap_content"/> 
    <TextView 
     android:id="@+id/Label2" 
     android:text="Label 2: " 
     android:layout_below="@id/Label1" 
     android:layout_width="200dp" 
     android:layout_height="wrap_content"/> 
    <TextView 
     android:id="@+id/Label3" 
     android:text="Label 3: " 
     android:layout_below="@id/Label2" 
     android:layout_width="200dp" 
     android:layout_height="wrap_content"/> 
    <TextView 
     android:id="@+id/Label4" 
     android:text="Label 4: " 
     android:layout_below="@id/Label3" 
     android:layout_width="200dp" 
     android:layout_height="wrap_content"/> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_toRightOf="@id/Label1"> 
     <TextView 
      android:id="@+id/Label6" 
      android:layout_width="100dp" 
      android:layout_height="wrap_content" 
      android:text="Points" 
      android:textStyle="bold" 
      android:textSize="25sp" 
      android:gravity="center_horizontal"/> 
     <TextView 
      android:id="@+id/LabelPoints" 
      android:layout_width="100dp" 
      android:layout_height="wrap_content" 
      android:text="8.6" 
      android:textStyle="bold" 
      android:textSize="25sp" 
      android:gravity="center_horizontal"/> 
    </LinearLayout> 
</RelativeLayout> 

답변

0

화면 크기/밀도가 다른 여러 장치에 전개하기 시작하면 사물의 외모로 인해 약간의 불안감이 생길 수 있습니다. 이 내 문제라면

는, 나는 여분의 LinearLayout을 사용하여 가중치를 사용하여 이러한 정렬 유혹 할 것입니다. 너무 늦기 아니라면 :) .. 다음이 당신을 도와줍니다

희망을 참조하십시오

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal"> 
    <LinearLayout android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_weight="1"> 
     <TextView 
      android:id="@+id/Label1" 
      android:text="Label 1: " 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
     <TextView 
      android:id="@+id/Label2" 
      android:text="Label 2: " 
     android:layout_below="@id/Label1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
     <TextView 
      android:id="@+id/Label3" 
      android:text="Label 3: " 
      android:layout_below="@id/Label2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
     <TextView 
      android:id="@+id/Label4" 
      android:text="Label 4: " 
      android:layout_below="@id/Label3" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:orientation="vertical" 
     android:layout_toRightOf="@id/Label1"> 
     <TextView 
      android:id="@+id/Label6" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Points" 
      android:textStyle="bold" 
      android:textSize="25sp" 
      android:gravity="center_horizontal"/> 
     <TextView 
      android:id="@+id/LabelPoints" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="8.6" 
      android:textStyle="bold" 
      android:textSize="25sp" 
      android:gravity="center_horizontal"/> 
    </LinearLayout></LinearLayout> 
0

마크, 나는 안드로이드 문서가 상대적으로 더 효율적임을 의미하기 때문에 좋은 방법이 아니다라고 생각합니다. 당신은 여기에서 찾을 수 있습니다 http://developer.android.com/guide/topics/ui/layout/relative.html

는 "이 중첩 된 뷰 그룹을 제거하고 성능을 향상, 평평 레이아웃 계층 구조를 유지할 수 있기 때문에 RelativeLayout의 사용자 인터페이스 설계를위한 매우 강력한 유틸리티입니다." 너무, TableLayout을 사용하여 수행 할 수

+0

이 작은 경우에 괜찮을거야 - 그는은 LinearLayouts에서 테이블 구조를 그림처럼 그렇지 않아 – ataulm

0

. 따라서 레이블을 행 (TableRow)에 추가 할 수 있습니다. 희망, 유용 당신을 위해 :-)

관련 문제