简体   繁体   中英

Manually arrange buttons in layout in Android app

I would like to know how to make a layout like this picture : http://www.noelshack.com/2014-13-1395752335-app.png

I have no idea how I can do that. I already have a LinearLayout with some buttons inside, but I don't know how to move them easily.

Thanks in advance for your help (and sorry for my bad english !)

If You are suggesting interactive moving of items, then You should search for "Drag and Drop". For example: Drag and drop for linearlayout's child views .

If you want to overlay one view over another - then use RelativeLayout and remember that latest view in xml layout has more Z axis value.

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

<Button
    android:id="@+id/button_below"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_centerVertical="true"
    android:text="ButtonBelow" />

<Button
    android:id="@+id/button_above"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_alignBottom="@+id/button_below"
    android:layout_alignParentLeft="true"
    android:layout_marginBottom="62dp"
    android:text="ButtonAbove" />

</RelativeLayout>

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM