-1

I just started with android development. I just need a screen with some buttons on it that can contact a webserver, to trigger an action there, but i have not even gotten that far.

When i add buttons to the layout, even if they are nicely sided by side, they end up ontop of each other, with the button created last ontop.

And furtermore i have changed the color, but it does not seem to be moved end up in the simulator.

This is a fresh design (2nd try) and i dont understand what is going on. I dont really know what files to include :)

I realize this is something simple, but im just overwhelmed

thank you Lasse

Phone and design view

LHK
  • 29
  • 3

1 Answers1

0

You're probably using a FrameLayout, which just stacks things on top of each other and only supports gravity.

For your use case, you can use a LinearLayout, a RelativeLayout or a ConstraintLayout. Here's an example using LinearLayout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:text="Select releases since last candy fix" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:layout_width="96dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="16dp"
            android:text="Button 1" />

        <Button
            android:layout_width="96dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="16dp"
            android:text="Button 2" />
    </LinearLayout>
</LinearLayout>

Have a look at the different layouts to see which one better fits your needs, ConstraintLayout would allow you to flatten your layout, which is good for performance.

Francesc
  • 25,014
  • 10
  • 66
  • 84