对象在relativelayout中的位置

问题描述 投票:0回答:4

我是Android的初学者。我使用Eclipse来编写我的应用程序。当我创建.xml类并且我想设置按钮的特定位置时,我使用此代码作为示例:

<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>

......但没有任何反应。它将按钮设置在一个角落里。我怎样才能让它出现在其他地方?

android position relativelayout android-scroll
4个回答
0
投票

你需要使用

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

0
投票

您需要使用定位参数,例如android:layout_below。有关详细信息,请参阅Relative Layout Guide


0
投票

您应该单击按钮并转到属性。这就是不同定位设置所在的位置。例如下面:@ + id / VIEW然后设置marin top:10dip。这将使您按下按钮10俯视VIEW。


0
投票
<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" />
© www.soinside.com 2019 - 2024. All rights reserved.