簡體   English   中英

安卓 如何用模糊效果開始活動?

[英]Android. How to start activity with blur effect?

是否可以從啟動的活動中看到啟動活動,並在背景上產生模糊效果?

例如,如果入門活動具有圖像,文本和按鈕,我希望看到它們與已啟動的活動(當前位於頂部,被啟動的活動布局部分隱藏)模糊。 黑色的透明度是否也可能?

編輯:
我知道如何制作透明的顏色。
我問是否有可能在兩項活動(堆棧頂部的一項和上一項活動)之間產生這些影響。

您可以使用支持庫中提供的RenderScript

public class BlurBuilder {
    private static final float BITMAP_SCALE = 0.4f;
    private static final float BLUR_RADIUS = 7.5f;

    public static Bitmap blur(Context context, Bitmap image) {
        int width = Math.round(image.getWidth() * BITMAP_SCALE);
        int height = Math.round(image.getHeight() * BITMAP_SCALE);

        Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
        Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);

        RenderScript rs = RenderScript.create(context);
        ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
        Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
        Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
        theIntrinsic.setRadius(BLUR_RADIUS);
        theIntrinsic.setInput(tmpIn);
        theIntrinsic.forEach(tmpOut);
        tmpOut.copyTo(outputBitmap);

        return outputBitmap;
    }
}

查看此鏈接以獲取更多詳細信息

或者您可以使用模糊

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM