0

我已经开始了一个布局,它应该如下所示:

理论

但我很难将 3 ImageView (Red) 移动到确切的位置。这是我所能得到的:

实际的

现在我的问题是,我想将三个 ImageView 设置为可点击,以路由到它们相应的屏幕,但这不能应用于我的布局,因为我只是使用 translateY 将 ImageView(blue) 向下移动,例如,60dp . 真正的 ImageView(blue) 位置比 ImageView(aqua) 的实际显示高 60dp。所以点击它不会影响任何事情。这是我的xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mypage_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/silver" >

<FrameLayout
    android:id="@+id/frame"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/table_1"
        android:layout_width="match_parent"
        android:layout_height="180dp"
        android:adjustViewBounds="true"
        android:background="@color/green" />

    <ImageView
        android:id="@+id/btn_top_page"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:adjustViewBounds="true"
        android:background="@color/maroon"
        android:clickable="true" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <RelativeLayout
            android:id="@+id/relative_left"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_toLeftOf="@+id/relative_center" >

            <ImageView
                android:id="@+id/btn_left"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:clickable="true"
                android:src="@color/aqua"
                android:translationY="60dp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/btn_left"
                android:layout_centerHorizontal="true"
                android:text="Left"
                android:textColor="#FFFFFF"
                android:translationY="65dp" />
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/relative_center"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp" >

            <ImageView
                android:id="@+id/btn_center"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:clickable="true"
                android:src="@color/fuchsia"
                android:translationY="70dp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/btn_center"
                android:layout_centerHorizontal="true"
                android:text="Center"
                android:textColor="#FFFFFF"
                android:translationY="75dp" />
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/relative_right"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_toRightOf="@id/relative_center" >

            <ImageView
                android:id="@+id/btn_right"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:clickable="true"
                android:src="@color/gray"
                android:translationY="60dp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/btn_right"
                android:layout_centerHorizontal="true"
                android:text="Right"
                android:textColor="#FFFFFF"
                android:translationY="65dp" />
        </RelativeLayout>
    </RelativeLayout>
</FrameLayout>

这是代码应该做的事情吗?任何帮助都可以。非常感谢。

4

1 回答 1

1

尝试使用 layout_marginTop 而不是 translationY。

于 2013-07-19T03:46:48.957 回答