Eclipse- Android アプリ 「正方形」ボタンのメニューを作成しようとしています - 3 つのボタンが並んでいます - 各ボタンには背景画像があります ...
列を同じ重みにすることはできましたが、次のことを考えると、ボタンの高さを常に幅と等しくする方法がわかりません。-将来、アプリケーションにさらに行を追加します。そのため、レイアウトを特定の行数に固有にしたくありません。つまり、行数に関係なく、ボタンは正方形にする必要があります(もちろん、どのデバイスの画面サイズでも)-背景画像をボタンに合わせて調整したい; つまり、ボタンは正方形のままで、背景画像はそれに準拠しています
これはこれまでの私のコードです:(同じbg画像を持つ3行のみ
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>