1

Eclipse- Android app I am trying to make a menu of "square" buttons - 3 buttons in a row - Each button has a background image ...

I was able to make the columns of equal weight , but I can't figure out how to make the heights of the buttons to be always equal to their widths, given that: - I will add more rows to the application in the future, so I dont want the layout to be specific to a certain number of rows ; i.e.: whatever the number of rows are, the buttons should be square (on any device screen size, of course) - I want the background images to adjust themselves to the buttons ; i.e: the button remains a square and the background image conforms to it

This is my code so far: (just three rows with the same bg image

<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>
Quaternion
  • 10,380
  • 6
  • 51
  • 102

1 Answers1

0

I think you must customize a list view to have the menu that could be added in to

for the shape that you want to be always square you must use nine-patch see here

SRah
  • 3
  • 2