If you use fixed dimensions for both width and height, you'll get a square, but you lose the nice auto-sizing LinearLayout does. In your case, you don't know the width of each button until after the layout is finished. The post() method in View is your friend.
final Button button1 = (Button) findViewById(R.id.button25);
first.post( new Runnable() {
public void run() {
LinearLayout.LayoutParams params =
(LinearLayout.LayoutParams) button1.getLayoutParams();
params.height = button1.getWidth();
}
});
To make sure buttons size correctly your layout should look something like this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="5"> <!-- or however many buttons there are -->
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
<!-- other buttons go here -->
</LinearLayout>
This only takes care of the first button, but you can figure out how to do the rest.