2010-12-06 15 views
0

私はアンドロイドには比較的新しいので、このレイアウトを行う良い方法があるのだろうかと思っています。私は4つのラベルが左側に縦に積み重ねられ、右側に2つの大きなフォントのラベルが必要です。エミュレータでこれを実行すると、それは私が必要とするものですが、より好ましい方法がありますか?物事のルックスによって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

マークではない場合、私はAndroidのドキュメントは相対的で、より効率的であることを意味しているため、それは良い方法ではないと思います。あなたはここでそれを見つけることができます: http://developer.android.com/guide/topics/ui/layout/relative.html

は「それは、ネストされたビュー・グループを排除し、パフォーマンスが向上し、平らなご レイアウト階層を保つことができるので、RelativeLayoutは、ユーザー インタフェースを設計するための非常に強力なユーティリティです。」

+0

小さなケースではうまくいくでしょう - 彼はLinearLayoutsからテーブル構造を描いているようではありません – ataulm

0

でも、TableLayoutを使用するとできます。したがって、行(TableRow)にラベルを追加することができます。うまくいけば、それはあなたのために便利です:-)

関連する問題