An Activity which has an image when i click the image
1)A fragment should be added in the middle of the parent activity
2)When the fragment appears the background of parent activity should get blurred/dimmed.
3)And clicking outside the fragment the fragment should disappear again.
(Same effect we get when we click contact image in whatsApp it opens an overlay) I have can add fragment successfully but the activity remains active.
How to achieve this effect? I have tried fragmentTransaction.setCustomAnimation(int,int) but it does not work.
Thank you.
You have two options:
DialogFragment
setting the layout in the onCreateView()
method. Fragment
with a background with alpha (for example #44000000
). Add the OnTouchListener
to the background view and in the onTouch()
method, dismiss the Fragment
. By the way, I would seriously recommend you the first option.
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.