Я хотел бы сконструировать рамку, используя 4 ImageView
для каждой верхней, нижней, левой и правой сторон этой рамки, как показано в следующем примере:
![enter image description here](https://i.stack.imgur.com/HHERZ.png)
Кажется простым, но мне действительно тяжело это делать. Я попытался использовать FrameLayout
вместе с layout_alignParentLeft|Right|Top|Bottom
, как показано ниже:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/camera_masque"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FFFFFF"
>
<ImageView
android:id="@+id/camera_top_masque"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_top_masque_photo"
android:layout_alignParentTop="true"
/>
<ImageView
android:id="@+id/camera_left_masque"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/ic_left_masque_photo"
android:layout_alignParentLeft="true"
/>
<ImageView
android:id="@+id/camera_right_masque"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/ic_right_masque_photo"
android:layout_alignParentRight="true"
/>
<ImageView
android:id="@+id/camera_bottom_masque"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_bottom_masque_photo"
android:layout_alignParentBottom="true"
/>
</FrameLayout>
Он хорошо работает для верхней и левой сторон, но не для других (как будто он размещает правую и нижнюю стороны на верхней стороне ...).
Я также пытался использовать RelativeLayout
так:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/camera_masque"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FFFFFF"
>
<ImageView
android:id="@+id/camera_top_masque"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_top_masque_photo"
android:layout_alignParentTop="true"
/>
<ImageView
android:id="@+id/camera_left_masque"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="-2dp"
android:src="@drawable/ic_left_masque_photo"
android:layout_below="@id/camera_top_masque"
/>
<ImageView
android:id="@+id/camera_right_masque"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/ic_right_masque_photo"
android:layout_marginRight="-2dp"
android:layout_below="@id/camera_top_masque"
android:layout_alignParentRight="true"
/>
<ImageView
android:id="@+id/camera_bottom_masque"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_bottom_masque_photo"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
Но то же самое, не работает, как ожидалось.
Есть идеи, что не так с моими раскладками? Как я мог сделать это?
Примечание. Размеры изображений: 640 * 114 пикселей (вверху, внизу) и 34 * 572 (слева, справа).
Спасибо!