2011-06-29 4 views
0

は、このXMLコードを見てみてください。Android:集中型TableLayout?

<TableLayout 
    android:id="@+id/tableLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="10dip" 
    android:isScrollContainer="true" 
    android:scrollbarStyle="outsideInset"> 

    <TableRow 
    android:id="@+id/tableRow1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 

    > 
     <ImageButton 
     <!-- Some Code --> 
     /> 
     <ImageButton 
     <!-- Some Code --> 
     /> 
     <ImageButton 
     <!-- Some Code --> 
     /> 
    </TableRow> 
</TableLayout> 

3 ImageButtonsは(正確に集中)私のデバイスで正常に表示されます。しかし、大画面の別のデバイスでアプリをテストすると、3つのイメージが左に揃えられているようです。

レイアウトを集中化する方法はありますか?画面の幅はどうでもいいですか?

答えて

1

私は右の方法で、あなたの問題を理解している場合、これは...それを行う必要があります...のLinearLayoutと

<TableLayout 
     android:id="@+id/tableLayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="10dip" 
     android:isScrollContainer="true" 
     android:scrollbarStyle="outsideInset" 
     android:gravity="center_Horizontal|Center_Vertical"> 
<TableRow 
android:id="@+id/tableRow1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:gravity="center_Horizontal|Center_Vertical" 
> 
+0

android:gravity = "center_Horizo​​ntal"は、TableRowでそれを解決します。ありがとう – iTurki

0

ラップと同様の形式ですべての画像ボタンをクリックします。各直線レイアウトの重力を中心に設定します。すべての線形レイアウトに対してlayout width = fill_parent。

関連する問題