我是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:layout_marginRight
android:layout_marginLeft
android:layout_marginTop
android:layout_marginBottom
您需要使用定位参数,例如android:layout_below。有关详细信息,请参阅Relative Layout Guide。
您应该单击按钮并转到属性。这就是不同定位设置所在的位置。例如下面:@ + id / VIEW然后设置marin top:10dip。这将使您按下按钮10俯视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" />