2012-01-25 32 views
6

Entonces, lo que estoy tratando de hacer es crear un fondo translúcido y borroso para un diseño lineal.Haciendo el diseño lineal translúcido y borroso

En este momento tengo un diseño lineal que es completamente negro que cubre cierta información que una clave debe comprarse para mostrar, sin embargo, me gustaría que se borre, no completamente cubierto, ya que arruina el diseño, necesita permanecer allí, simplemente borroso e ilegible.

Gracias por su ayuda!

+0

no estoy seguro, no intento de u poner esto en etiqueta en Manifiesto? android: theme = "@ android: style/Theme.Dialog" –

Respuesta

2

No estoy seguro para Linearlayout. Pero para tu actividad puedes probar esto.

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

y utilizar el método setContentView(R.layout.your_layout);

+1

sí, eso funciona para la ventana, sin embargo, en el diseño en sí no es así, para mayor claridad, sus dos diseños lineales lado a lado (en paisaje) y el derecho necesita ser borroso, pero sigue ahí, y el fondo no es sólido, así que no puede ser cubierto, porque aún quiero mostrar lo que hay pero ser ilegible – Samuel

+0

No pude encontrar una forma de solicitar un diseño lineal. Pero tengo una idea. Puede usar la ventana para fondo translúcido. Y donde quiera que desee fondo puede aplicar fondo. Y no aplique el fondo para los que no quiere. Por ejemplo, en su caso puede aplicar fondos para uno de sus diseños lineales a la izquierda y no aplicar ningún fondo para el otro diseño lineal. Creo que esto podría funcionar Aunque no es la forma correcta. – san

+0

Sin embargo, la ventana tiene un fondo que es una imagen no sólida – Samuel

0

Si desea realizar cualquier opinión del fondo translúcido a continuación, utilizar a continuación el código

android:background="@null" 

me funciona para EditarTexto. Y que yo sepa que debería funcionar para cualquier view.So vez tratar de éste

+0

translucent! = transparente – Graham

0

¿Qué tal intentar GLSurfaceView:

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

Dentro de Android SDK hay un ejemplo en conseguir superficie translúcida (app/TranslucentActivity.java), estableciendo esencialmente el canal alfa:

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's 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); 
} 

para otros hilos sobre el uso de canal alfa se refieren a:

Alpha Channel Blur

How can I blur and dim an image to be used as an activity background?

blur a image at android

Otro ejemplo es la aplicación/TranslucentBlurActivity.java (de 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

En el segundo ejemplo, la bandera 'FLAG_BLUR_BEHIND' está en desuso. – Ayoub

Cuestiones relacionadas