bytedance / scene

Android Single Activity Framework compatible with Fragment.
Apache License 2.0
2.08k stars 199 forks source link

DialogScene的写法仿照,但是背景无法实现半透明 #44

Closed Iridescentangle closed 4 years ago

Iridescentangle commented 4 years ago

image 最关键的在于,给onCreateView返回的View或者onViewCreated的View设置一层半透明的背景色,对吗,是这么写的,但是不太好用... 此为Demo中的DialogScene实现思路: `public class DemoDialogWithDimScene extends Scene { @NonNull @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { FrameLayout layout = new FrameLayout(requireSceneContext()); layout.setBackgroundColor(Color.parseColor("#99000000"));

    TextView textView = new TextView(getActivity());
    textView.setText(getNavigationScene().getStackHistory());
    textView.setBackgroundColor(ColorUtil.getMaterialColor(getResources(), 1));
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(600, 600);
    layoutParams.gravity = Gravity.CENTER;

    layout.addView(textView, layoutParams);

    layout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            requireNavigationScene().pop();
        }
    });

    return layout;
}

} 下面是我的仿照思路: class VoucherScene : BaseViewModelScene() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle? ): View { val layout = FrameLayout(sceneContext!!) layout.setBackgroundColor(Color.parseColor("#99000000")) val layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) layoutParams.gravity = Gravity.CENTER val child = inflater.inflate(getLayoutId(), null) layout.addView(child, layoutParams) return layout } }`

Iridescentangle commented 4 years ago

代码插入惨不忍睹...

qii commented 4 years ago

push 时候的代码贴一下

Iridescentangle commented 4 years ago

OK 今天排查了一下,Push的时候要传递PushOptions.Builder().setTransluscent(true).build(),以后就知道这个情况了,非常感谢!