RelativeLayout - 按钮位置错误

时间:2013-11-04 13:05:12

标签: android eclipse

我第一次使用RelativeLayout,并按如下方式定位了两个按钮:

<?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"
    android:orientation="vertical" >

    <ImageButton
        android:id="@+id/flybut"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="10dp"
        android:layout_centerVertical="true"
        android:background="#00000000"
        android:src="@drawable/flybut" />

    <ImageButton
        android:id="@+id/jumpbut"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/flybut"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="10dp"
        android:layout_marginBottom="10dp"
        android:background="#00000000"
        android:src="@drawable/jumpbut" />
</RelativeLayout>

因此,flybut位于距离屏幕左侧10dp的位置,并且在屏幕的中心位置。跳线也位于屏幕左侧10dp处,距离flybut上方10dp处。这一切看起来与eclipse GUI中的预期完全一样,但在运行时跳转是在错误的位置。它从左侧正确10dp,但它在屏幕的最顶部再次卡住。我做错了吗?

0 个答案:

没有答案