user3107610
user3107610

Reputation: 77

How to make group button?

I have 3 buttons. And the problem is I can't put 3 buttons in centre of layout. The problem will show when I make my phone horizontal, the buttons will show at left of layout not at center.

Upvotes: 0

Views: 191

Answers (1)

venom2124
venom2124

Reputation: 168

You will need to embed a relative layout inside the linear layout. Similar to what is shown below. This should allow you to get the buttons in a group that can be manipulated better that if a LinearLayout is maintained. One other thing do you have a separate layout for the landscape orientation?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<RelativeLayout 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal" >

    <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>


</RelativeLayout>

Upvotes: 2

Related Questions