Android的DataBinding是否与Transitions / Scenes框架一起使用?
作者:互联网
Android的DataBinding库是否与Transitions framework一起使用?
Scene scene = Scene.getSceneForLayout(this, R.layout.creditcardentryview_scene2_expanded, this.getContext());
TransitionManager.go(scene);
scene2Binding = CreditcardentryviewScene2ExpandedBinding.bind(this);
尝试上面的代码会抛出此错误:视图上的视图标记不正确:null
解决方法:
您应该在创建场景之前绑定布局:
CreditcardentryviewScene2ExpandedBinding binding = CreditcardentryviewScene2ExpandedBinding.inflate(getLayoutInflater(), this, false);
Scene scene = new Scene(this, binding.getRoot());
TransitionManager.go(scene);
绑定(this)失败,因为这不是绑定视图.这是场景根!所以你也可以这样做:
Scene scene = Scene.getSceneForLayout(this, R.layout.creditcardentryview_scene2_expanded, this.getContext());
TransitionManager.go(scene);
scene2Binding = CreditcardentryviewScene2ExpandedBinding.bind(this.getChildAt(0));
标签:android,data-binding,android-transitions,android-databinding 来源: https://codeday.me/bug/20190727/1555662.html