V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
HexHub
HexHub,一站式SSH、Docker、数据库连接管理工具,支持多种主流数据库、多窗口分屏、智能SQL编辑、极速数据处理、批量命令、云端同步,支持SSH跳板机、命令广播、历史命令、SFTP多端文件互传。
Promoted by xiwh
Jimjay
V2EX  ›  问与答

有没有更好的方法模糊一个 popup window 的背景

  •  
  •   Jimjay · 2018-02-10 19:32:34 +08:00 · 1397 次点击
    这是一个创建于 2729 天前的主题,其中的信息可能已经有所发展或是发生改变。

    第一先想到的肯定都是在 popup window 出来之前先截屏,然后模糊这个 bitmap,最后把它设成 popup 的背景。

    但是在我的项目里,popup 是由一个 recyclerview 在 fragment 里 item tiggered 的。 理所当然, 这个 item 的回调方法是在这个 recyclerview 的 adapter 里,code like this

    item.setOnClickListener(new OnClickListener){
        // capture the screen at this moment
        // trigger the popup window, and set the blurred bitmap to the background of         // the popup
        }
    

    重点是 capture screen 那一 part 需要 activity 的引用,不然 get 不到 decor view。但是项目设计用的是 mvvm 模式,adapter 属于 view model 部分, 不能持有 activiy 引用,用了 databinding 框架,code like this

    @BindingAdapter("bind:data")
    public static void setData(RecyclerView recyclerView, List<ItemData> data){
        if (data != null) {
            recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext(), LinearLayoutManager.HORIZONTAL, false));
            recyclerView.setAdapter(new ItemsAdapter(recyclerView.getContext(), data));
        }
    

    所以 adapter 拿不到 activity 引用, 所以想问大神, 有什么办法模糊 popup 背景?

    Note that: 重写 adapter 传入 activity,只能算一个折中办法

    目前尚无回复
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1137 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 23:42 · PVG 07:42 · LAX 16:42 · JFK 19:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.