是否有可能制作一个模糊其背后所有内容的布局

时间:2016-05-10 08:03:42

标签: android button blur blurry

我想创建一个模糊的透明服务应用程序,使我的应用程序背后的一切看起来模糊,问题是,我需要截取几乎不可能的整个设备屏幕截图

是否有诀窍让我的背景看起来模糊?或者是否有任何技巧可以使某些阿尔法可以使视图背后的一切看起来模糊?

EDITED
很抱歉迟到的回复,说实话,这个答案不是我需要的,但仍然感谢您的回复,我需要的是这样的:

  

例如,我有2 layer布局:
  第A层,此图层是背景
  第B层,此图层是我的应用层

我的应用是透明的,例如,如果您打开Settings,然后打开我的应用,那么我的应用会弹出,Settings仍会显示,Settings视图仍然可以可以看到,但我想要那个"设置"看起来很模糊。

所以一般来说,我需要截取当前Settings视图的屏幕截图,然后使用FastBlurRenderScript或其他任何内容模糊它,问题是我截屏时Settings,花了很长时间。这样:

我是否有任何技巧可以覆盖Settings视图,即设置视图是图层A,包含图层B.我需要对图层B做些什么才能使图层B后面的所有内容都模糊,任何的想法?

1 个答案:

答案 0 :(得分:0)

在Layout文件夹中创建 statoast.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_layout_root"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<TextView
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:textSize="30sp"
    android:textStyle="bold"
    android:gravity="center_horizontal"
    android:textColor="#ffffff"
    android:padding="20dp"
    android:background="@color/color_statoastBG"
    android:layout_gravity="center_horizontal" />
</LinearLayout>

然后将此行插入位于“值”文件夹中的 colors.xml 文件的<resources></resources>内(此处定义颜色和Alpha值 - alpha是两个第一个值在&#34;#&#34;)之后:

    <color name="color_statoastBG">#ccffcc00</color>

然后通过调用此函数从Java中吐出你的吐司:

public void staToast() {
    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.statoast, (ViewGroup) findViewById(R.id.toast_layout_root));
    TextView text = (TextView) layout.findViewById(R.id.text);
    text.setText("This is a custom toast\n\nYou can use an ImageView here too");
    Toast toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
    toast.setDuration(Toast.LENGTH_LONG);
    toast.setView(layout);
    toast.show();
}

当然,您必须提供必要的代码来拍摄设备实际图像,然后将其放在此自定义吐司上方以获得您想要的效果。但是......不知道如何或者你是否会使用这一切获得边距和边界。请回复你的想法并原谅任何错误/不一致。祝福。