1、margin可以设置为负数
平时我们设置margin
的时候都习惯了是正数的, 其实是可以用负数的。
<?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">
<ImageView
android:id="@+id/imgback"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerInParent="true"
android:background="@drawable/imgback"/>
<ImageView
android:id="@+id/imgcancle"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignTop="@+id/imgback"
android:layout_alignRight="@+id/imgback"
android:layout_marginTop="-20dp"
android:layout_marginRight="-20dp"
android:background="@drawable/cancle"/>
</RelativeLayout>