2011-07-21 8 views
1

こんにちはAndroidの専門家、画面上に水平方向にスペースがない場合は、次に垂直方向に使用できるスペースに移動しますか?

は、私は次のようなレイアウトを持っている:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:gravity="center_horizontal"> 
<ImageButton android:id="@+id/ImageButton01" 
android:layout_width="80px" 
android:layout_height="80px" 
android:background="@drawable/projects_badge" 
android:layout_margin="10px"/> 
<ImageButton android:id="@+id/ImageButton02" 
android:layout_width="80px" 
android:layout_height="80px" 
android:background="@drawable/projects_badge" 
android:layout_margin="10px"/> 
<ImageButton android:id="@+id/ImageButton01" 
android:layout_width="80px" 
android:layout_height="80px" 
android:background="@drawable/projects_badge" 
android:layout_margin="10px"/> 
<ImageButton android:id="@+id/ImageButton02" 
android:layout_width="80px" 
android:layout_height="80px" 
android:background="@drawable/projects_badge" 
android:layout_margin="10px"/> 
<ImageButton android:id="@+id/ImageButton01" 
android:layout_width="80px" 
android:layout_height="80px" 
android:background="@drawable/projects_badge" 
android:layout_margin="10px"/> 
<ImageButton android:id="@+id/ImageButton02" 
android:layout_width="80px" 
android:layout_height="80px" 
android:background="@drawable/projects_badge" 
android:layout_margin="10px"/> 
</LinearLayout> 

このレイアウトの画像ボタン画面の外に出ると見えなくなります。私は新しい行から始めたいと思います。

ご協力いただければ幸いです。

ありがとうございます。 :)

+0

[この質問](http://stackoverflow.com/questions/549451/line-breaking-widget-layout-for-android)の最初の回答はおそらくあなたを助けることができますか? – scessor

+0

@scessorありがとう、これは私が探していたものです。私は本当にありがとうございます:D –

答えて

4

合計ボタンのピクセル値は画面サイズのピクセル値より大きく、アンドロイドには自動的にラインをラップするビューはありません。ボタンを次の行に移動するには、別のレイアウトビューを作成し、その中にいくつかのボタンを配置する必要があります。

あなたはまた、レイアウト(複数可)の向きでプレイすることもできます。http://developer.android.com/reference/android/widget/LinearLayout.html#attr_android:orientation

また、側面として、あなたは本当に代わりにPXのDPまたはSPを使用する必要があります。 What is the difference between "px", "dp", "dip" and "sp" on Android?

+0

あなたの答えをありがとう。 :) –

+0

ようこそ。 – Noah

関連する問題