I would like to create this layout
Then I found this
So I created this layout
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="com.myapplication.MainActivity">
<View
android:id="@+id/square"
android:layout_width="100dp"
android:background="#ff0000"
android:layout_centerInParent="true"
android:layout_height="100dp"/>
<ImageView
android:id="@+id/circle"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignTop="@id/square"
android:layout_alignLeft="@id/square"
android:layout_marginRight="25dp"
android:layout_marginBottom="25dp"
android:src="@mipmap/circle" />
</RelativeLayout>
But the layout margin does not have any effect
The output is same to
<ImageView
android:id="@+id/circle"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignTop="@id/square"
android:layout_alignLeft="@id/square"
android:src="@mipmap/circle" />
How to align a view's center point to certain point of other view?