2011-11-15 6 views
1

EDITED:私は解決策を見つけました。ありがとうございました!複雑なコンポーネント配置のアンドロイドテーブルレイアウト

私はAndroidのAppの次の画面を作成したい: ideal screen

今私は、この持っている:テキストはでき

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" 
    android:weightSum="1" > 

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:layout_weight=".65" 
     android:weightSum="5" > 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="TOURNAMENT: " 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:layout_weight="1" 
      android:layout_marginLeft="10dp"/> 
     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="GAME: " 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:layout_weight="1" 
      android:layout_marginLeft="10dp" /> 
     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="BEST OF: " 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:layout_weight="1" 
      android:layout_marginLeft="10dp" /> 
     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="BRACKET STYLE: " 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:layout_weight="1" 
      android:layout_marginLeft="10dp" /> 

    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:layout_weight=".35" 
     android:weightSum="5" > 

     <EditText 
      android:id="@+id/editText1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:layout_marginRight="10dp" /> 

     <EditText 
      android:id="@+id/editText1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:layout_marginRight="10dp" /> 

     <EditText 
      android:id="@+id/editText1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:layout_marginRight="10dp" /> 
     <EditText 
      android:id="@+id/editText1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:layout_marginRight="10dp" /> 

     <RelativeLayout 
      android:id="@+id/linearLayout1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:layout_weight="1" > 

      <Button 
       android:id="@+id/button2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_centerVertical="true" 
       android:layout_marginRight="15dp" 
       android:text="CANCEL" /> 

      <Button 
       android:id="@+id/button1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_toLeftOf="@+id/button2" 
       android:text="CREATE" /> 

     </RelativeLayout> 

</LinearLayout> 

</LinearLayout> 

:このコードで current dev

をandroid:gravity = "right"を使用して右側に揃えましたが、どうすればそれを垂直に中心に置くことができますか?

- > AISHHは、それはです:アンドロイド:重力= "center_vertical |右"

をありがとう!

+1

使用2 '向きでLinerLayout'垂直および設定を' layout_weight'に応じません。 –

答えて

0

これは私が思いついた実装です。最高のが、私のために働いた:)

<LinearLayout 
    android:id="@+id/linearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:layout_weight=".65" 
    android:weightSum="5" 
    android:paddingTop="10dp" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="TOURNAMENT: " 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:layout_weight="1" 
     android:layout_marginLeft="10dp" 
     android:gravity="center_vertical|right"/> 
    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="GAME: " 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:layout_weight="1" 
     android:layout_marginLeft="10dp" 
     android:gravity="center_vertical|right"/> 
    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="BEST OF: " 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:layout_weight="1" 
     android:layout_marginLeft="10dp" 
     android:gravity="center_vertical|right"/> 
    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="BRACKET STYLE: " 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:layout_weight="1" 
     android:layout_marginLeft="10dp" 
     android:gravity="center_vertical|right"/> 

    <!-- fill up the space so that the components on top are displayed correctly --> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:layout_weight="1" 
     android:layout_marginLeft="10dp" 
     android:gravity="center_vertical|right"/> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/linearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:layout_weight=".35" 
    android:weightSum="5" 
    android:paddingTop="10dp" > 

    <EditText 
     android:id="@+id/tourName" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:layout_marginRight="10dp" 
     android:gravity="center_vertical|left" /> 

    <Spinner 
     android:id="@+id/spinGameName" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:layout_marginRight="10dp" 
     android:gravity="center_vertical|left" /> 

    <Spinner 
     android:id="@+id/spinBestOf" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:layout_marginRight="10dp" 
     android:gravity="center_vertical|left" /> 

    <Spinner 
     android:id="@+id/spinBracketType" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:layout_marginRight="10dp" 
     android:gravity="center_vertical|left" /> 

    <RelativeLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:layout_weight="1" > 

     <Button 
      android:id="@+id/btnCancel" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      android:layout_marginRight="15dp" 
      android:text="CANCEL" /> 

     <Button 
      android:id="@+id/btnCreate" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:layout_toLeftOf="@+id/btnCancel" 
      android:text="CREATE" /> 

    </RelativeLayout> 

</LinearLayout> 

1

まあ、TableLayoutは良いアイデアではありません。 RelativeLayoutと内部にネストされたLinearLayoutを試してみてください。

このような何か試してみてください:私はこのような同様のレイアウトを行ってきた

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentTop="true" 
     android:id="@+id/first_linear" 
     android:orientation="vertical"> 
     <!-- Note that for text view,and editText you might need to use certain values (dip values) cuz wrap content will try to arrange the view --> 
     <TextView 
      android:id="@+id/first_text_label" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"/> 
     <EditText 
      android:id = "@+id/first_edit_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"/> 

    </LinearLayout> 
    <!-- we align all the following linearlayouts below the first --> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/first_linear" 
     android:id="@+id/second_linear" 
     android:orientation="vertical"> 
     <TextView 
      android:id="@+id/second_text_label" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"/> 
     <EditText 
      android:id = "@+id/second_edit_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"/> 

    </LinearLayout> 

<!-- add all the layouts like those from above --> 

<!-- ...... --> 
<!-- after you added all the fields you can add a linear layout containing two buttons to float below the last one --> 

1

を:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" 
android:layout_height="fill_parent" android:layout_width="fill_parent" 
> 
    <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0"> 
     <LinearLayout android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="fill_parent"> 
      <TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:stretchColumns="1" android:shrinkColumns="1"> 
       <TableRow android:layout_width="fill_parent" android:layout_height="wrap_content"> 
        <TextView android:text="Value1" android:gravity="right" /> 
        <EditText android:singleLine="true" android:id="@+id/editTextVal1" /> 
       </TableRow> 
       <TableRow android:layout_width="fill_parent" android:layout_height="wrap_content"> 
        <TextView android:text="Long name value2" android:gravity="right" /> 
        <EditText android:singleLine="true" android:id="@+id/editTextVal1" /> 
       </TableRow> 
      </TableLayout> 
     </LinearLayout> 
    </ScrollView> 
    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0.0"> 
     <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Save" /> 
     <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Cancel" /> 
    </LinearLayout> 
</LinearLayout> 

スクロールパネルは下のボタンを持っているためにそこにあります設定が長くなった場合に備えて、常に画面の

関連する問題