Android 的数据绑定是否适用于 Transitions/Scenes 框架?
Does Android's DataBinding work with the Transitions/Scenes framework?
Android的DataBinding library work with the 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
您必须使用 DataBindingUtil.inflate()
自行扩充视图
并用膨胀的视图构建场景。 https://developer.android.com/reference/android/transition/Scene.html#Scene(android.view.ViewGroup, android.view.ViewGroup)
.bind(this)
仍然失败,因此您必须手动管理生成的绑定。
您应该在创建场景之前绑定布局:
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));
Android的DataBinding library work with the 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
您必须使用 DataBindingUtil.inflate()
并用膨胀的视图构建场景。 https://developer.android.com/reference/android/transition/Scene.html#Scene(android.view.ViewGroup, android.view.ViewGroup)
.bind(this)
仍然失败,因此您必须手动管理生成的绑定。
您应该在创建场景之前绑定布局:
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));