Closed Iridescentangle closed 4 years ago
最关键的在于,给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 } }`
下面是我的仿照思路:
代码插入惨不忍睹...
push 时候的代码贴一下
OK 今天排查了一下,Push的时候要传递PushOptions.Builder().setTransluscent(true).build(),以后就知道这个情况了,非常感谢!
最关键的在于,给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"));
}() {
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
}
}`
下面是我的仿照思路:
class VoucherScene : BaseViewModelScene