I would like to make button (the one between two other buttons) Square.
I tried to use following code:
toggleButton = (ToggleButton) findViewById(R.id.activity_dictionary_toggleButton1);
LinearLayout.LayoutParams toggleButtonLayoutParams = (LayoutParams) toggleButton.getLayoutParams();
toggleButtonLayoutParams.width = toggleButtonLayoutParams.height;
toggleButton.setLayoutParams(toggleButtonLayoutParams);
But it is not working (Button look like on the above image). Here is part of my XML file:
<LinearLayout
android:id="@+id/activity_dictionary_linearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp" >
<Button
android:id="@+id/activity_dictionary_button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="0.4"
android:enabled="false"
android:maxWidth="200dp"
android:text="Clear"
android:textColor="@android:color/white" />
<ToggleButton
android:id="@+id/activity_dictionary_toggleButton1"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="0.2"
android:background="@drawable/settings"
android:text="ToggleButton" />
<Button
android:id="@+id/activity_dictionary_button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="0.4"
android:enabled="false"
android:maxWidth="200dp"
android:text="Recognize"
android:textColor="@android:color/white" />
</LinearLayout>
What should I change?
Update: android:layout_weight="0.2"
is deleted, but Button still doesn't change its size when I try to do it through code (it is round but very small).