Question

I'm a beginner in Android. I use Eclipse to program my app. When I create an .xml class and I want to set the specific position of a button, I use this code for example:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/fm"
    android:baselineAligned="false"
    android:gravity="end" >

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:scrollX="100dp"
    android:scrollY="30dp"
    android:text="@string/edad" />

</RelativeLayout>

... but nothing happens. It sets the button in a corner. How can I get it to appear elsewhere?

Was it helpful?

Solution

you need to use

android:layout_marginRight
android:layout_marginLeft 
android:layout_marginTop
android:layout_marginBottom 

OTHER TIPS

You need to use positioning parameters such as android:layout_below. See the Relative Layout Guide for details.

You should click the button and go property. That's where the diffrent positioning settings are located. For example below :@+id/VIEW then set marin top : 10dip. This will set you button 10 dip below VIEW.

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

android:layout_marginLeft="100dp"
android:layout_marginTop="30dp"
android:text="@string/edad" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top