有的时候,我们需要一个View覆盖在另外一个View上,并且需要这个View覆盖于另一个View特定的位置
下面根据实现一个类似于其它App上的历史记录标签或者热点标签的Demo来讲解
示例:
想实现上面这种效果,首先要分清button与其右上角的deleteView的位置关系,从图中可以看出,deleteView的中心是button的右上角
所以,可以让deleteView的右边与button的右边相等(这样deleteView的右边就是由button的右边来限制),然后deleteView距离右边-15dp
deleteView的上边与button的上边相等,然后距离上边-15dp,好了,贴上代码
<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"