在Constraintlayout android中应用ConstraintSet时,视图消失

时间:2017-12-11 16:18:41

标签: android-constraintlayout

开始时,ImageView是水平居中的。我将视图移动到Kotlin的左侧。应用后,ImageView消失。我没有任何线索来调试此问题

enter image description here

 override fun onViewCreated(view: View, savedInstanceState: Bundle?){
        super.onViewCreated(view, savedInstanceState)
        applyConstraintSet.clone(vConstraint)

}

  private fun startAnimation() {
     applyConstraintSet.setHorizontalBias(R.id.ivAvatar, 0.2F)

     val transition = AutoTransition()
         transition.duration = 1500
         transition.interpolator = AccelerateDecelerateInterpolator()

TransitionManager.beginDelayedTransition(vConstraint, transition)

     applyConstraintSet.applyTo(vConstraint)

}

XML

<android.support.constraint.ConstraintLayout
    android:id="@+id/vConstraint"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/ivAvatar"
        android:layout_width="64dp"
        android:layout_height="64dp"
        android:layout_marginBottom="84dp"
        android:scaleX="0"
        android:scaleY="0"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        fresco:roundAsCircle="true" />


</android.support.constraint.ConstraintLayout>

1 个答案:

答案 0 :(得分:1)

我今天也有同样的问题。 我通过为id的所有孩子添加ConstraintLayout来修复此问题。 它适用于我version 1.0.2