简体   繁体   中英

Overlay Image over view corner

I am attempting to draw the medal overlaying the corner of the score screen shown here

There is an transparent layout holding the buttons and a RelativeLayout (black edge box), which holds the interior box (grey box) that contains the rest of the data. I tried adding the medal to the top left corner of the interior RelativeLayout and giving it negative margins, but that just cuts it off at the edge of the view. Adding it to the transparent layout puts it behind the corner.

How can I force the medal to overlay that corner? I'd prefer to do it in xml if possible, but any suggestions are welcome.

You can also achieve this by setting the android:clipChildren="false" and android:clipToPadding="false" attributes on the parent view (and if that doesn't work, set it on all the ancestor view groups as well, eventually it will work).

In the xml layout, an element that define after will overlay the element that define before. So, you could change layout to something like this:

<LinearLayout>

<LinearLayout> <!--grey box --> </LinearLayout>

<ImageView src="medal" android:layout_marginLeft="-250dip"/>
<!-- change the amount of marginLeft to your desire -->

</LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM