Android DataBinding库是否适用于Transitions framework?
Scene scene = Scene.getSceneForLayout(this, R.layout.creditcardentryview_scene2_expanded, this.getContext());
TransitionManager.go(scene);
scene2Binding = CreditcardentryviewScene2ExpandedBinding.bind(this);
尝试上述代码会引发此错误:view tag isn't correct on view:null
答案 0 :(得分:8)
您应该在创建场景之前绑定布局:
CreditcardentryviewScene2ExpandedBinding binding = CreditcardentryviewScene2ExpandedBinding.inflate(getLayoutInflater(), this, false);
Scene scene = new Scene(this, binding.getRoot());
TransitionManager.go(scene);
bind(this)
失败,因为this
不是绑定视图。 this
是场景根!所以你也可以这样做:
Scene scene = Scene.getSceneForLayout(this, R.layout.creditcardentryview_scene2_expanded, this.getContext());
TransitionManager.go(scene);
scene2Binding = CreditcardentryviewScene2ExpandedBinding.bind(this.getChildAt(0));
答案 1 :(得分:-1)
您必须使用DataBindingUtil.inflate()
并使用膨胀的视图构建场景。 https://developer.android.com/reference/android/transition/Scene.html#Scene(android.view.ViewGroup,android.view.ViewGroup)
.bind(this)
仍然失败,因此您必须手动管理生成的绑定。