0

I want to add two buttons in a single linear layout with horizontal orientation, I want my buttons to be stretched if the screen is bigger and contracted if the screen is small, what should I do to keep those exactly the same size together?

Fill parent or match parent causes only one to be displayed on the screen, what should be done to make both of them visible at the same time on any screen size?

1 Answer 1

1

give both of them the following properties :

weight =1
layout_width=fill_parent

here is a working code

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Button 1" >
    </Button>

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Button 2" >
    </Button>

</LinearLayout>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.