我已經放在按鈕和ImageView的上RelativeLayout的,並且這些按鈕完全有條件在Nexus 5:How it looks on Nexus 5如何將按鈕鏈接到Image上的特殊位置?
不過在Nexus One上它改變了很多:How it looks on Nexus One
這裏是我的XML代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
app:srcCompat="@drawable/main_menu_top" />
<ImageView
android:id="@+id/imageView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
app:srcCompat="@drawable/main_menu_center"
android:layout_below="@+id/imageView6" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/imageView6">
</RelativeLayout>
<Button
android:id="@+id/top_left_button"
android:layout_width="105dp"
android:layout_height="105dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/imageView6"
android:layout_marginLeft="77dp"
android:layout_marginStart="77dp"
android:layout_marginTop="38dp"
android:background="@drawable/button_main_menu_port"
android:text="Example" />
<Button
android:id="@+id/top_right_button"
android:layout_width="105dp"
android:layout_height="105dp"
android:background="@drawable/button_main_menu_port"
android:text="Example"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="80dp"
android:layout_marginEnd="80dp"
android:layout_alignBottom="@+id/top_left_button" />
<Button
android:id="@+id/bot_left_button"
android:layout_width="105dp"
android:layout_height="105dp"
android:layout_alignLeft="@+id/top_left_button"
android:layout_alignParentBottom="true"
android:layout_alignStart="@+id/top_left_button"
android:layout_marginBottom="39dp"
android:background="@drawable/button_main_menu_port"
android:text="Example" />
<Button
android:id="@+id/bot_right_button"
android:layout_width="105dp"
android:layout_height="105dp"
android:layout_alignBottom="@+id/bot_left_button"
android:layout_alignLeft="@+id/top_right_button"
android:layout_alignStart="@+id/top_right_button"
android:background="@drawable/button_main_menu_port"
android:lines="2"
android:maxLines="2"
android:minLines="2"
android:text="Example" />
</RelativeLayout>
</LinearLayout>
但是,這些按鈕需要位於此圖像中的菱形位置。
您能張貼您的預期結果的圖像嗎? – FAT
檢查Nexus 5的分辨率屏幕截圖 – NullOne