Android LinearLayout with evenly space buttons

Step 1: Set the android:layout_width="0dp"
Step 2: Set the android:layout_weight equally among all button with sum equal to 1.0

Here is sample code
<LinearLayout android:id="@+id/linearLayout3"
 android:layout_height="wrap_content" android:orientation="horizontal"
 android:layout_width="match_parent">
 <Button android:text="Reset Form" android:layout_height="wrap_content"
  android:id="@+id/clear" android:layout_width="0dp"
  android:layout_weight=".5" />
 <Button android:text="Submit Form" android:layout_height="wrap_content"
  android:id="@+id/submit" android:layout_width="0dp"
  android:layout_weight=".5" />
</LinearLayout>

Android layout space buttons equally

No comments:

Post a Comment

NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.