Create a linear layout of translucent and blurry

So, I'm trying to create a transparent and blurry background for a linear layout.

Right now I have a linear layout that is completely black, covers some of the information that a key must be purchased for showing, however I would like it to be blurred and not completely covered, since it destroys the layout, it should stay there, just blurry and illegible.

Thanks for your help!

+6
source share
3 answers

I'm not sure about Linringayout. But for your work, you can try this.

GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

and use the setContentView(R.layout.your_layout); method setContentView(R.layout.your_layout);

+2
source

If you want to make any background view translucent, use the code below

  android:background="@null" 

It works for EditText. And AFAIK it should work for any kind. So try this one

0
source

How to try GLSurfaceView:

http://developer.android.com/resources/articles/glsurfaceview.html

The Android SDK has an example of getting a translucent surface (app / TranslucentActivity.java), which essentially sets the alpha channel:

 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create our Preview view and set it as the content of our // Activity mGLSurfaceView = new GLSurfaceView(this); // We want an 8888 pixel format because that required for // a translucent window. // And we want a depth buffer. mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); // Tell the cube renderer that we want to render a translucent version // of the cube: mGLSurfaceView.setRenderer(new CubeRenderer(true)); // Use a surface format with an Alpha channel: mGLSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT); setContentView(mGLSurfaceView); } 

For other streams when using the alpha channel, refer to:

Alpha channel blur

How can I blur and reduce the image that will be used as the background of the operation?

blur image on android

Another example is the /TranslucentBlurActivity.java application (from the Android SDK):

 public class TranslucentBlurActivity extends Activity { /** * Initialization of the Activity after it is first created. Must at least * call {@link android.app.Activity#setContentView setContentView()} to * describe what is to be displayed in the screen. */ @Override protected void onCreate(Bundle icicle) { // Be sure to call the super class. super.onCreate(icicle); // Have the system blur any windows behind this one. getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); // See assets/res/any/layout/translucent_background.xml for this // view layout definition, which is being set here as // the content of our screen. setContentView(R.layout.translucent_background); } } 
0
source

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


All Articles