Android: How to make modal user view?

I would like to make my own dialog, fully drawn as a user view. Can I display it in such a way that it displays above all other types and that all touch events, even those that are outside the dialog area, are redirected to the dialog?

+4
source share
3 answers

I find that using transparent activity and startActivityForResult () gives me complete freedom as I want my β€œdialogue” to look and behave. Therefore, I suggest you check: How to create transparent activity on Android?

With full screen and dark background of your choice:

<style name="Theme.Transparent" parent="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"> <item name="android:windowBackground">@color/transparentActivityBackground</item> </style> 

Then in strings.xml:

 <color name="transparentActivityBackground">#55000000</color> 

If you want to blur the screen of a previous operation, use this line before setting SetContentView:

 this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND); 
+9
source

This should be possible by setting the height / width of the root element with nothing but fill_parent .

You can also achieve this by creating a custom theme that inherits from the built-in Android dialogue theme.

http://developer.android.com/guide/topics/ui/themes.html

+1
source

Here is my workaround.

First, get the child representation of the contents of the decor view, which is FrameLayout , using Window#getDecorView().findViewById(android.R.id.content) .

Then add your custom view to this FrameLayout and it will be at the top of the other views.

0
source

Source: https://habr.com/ru/post/1340531/


All Articles