使用自定义 attributeSet 的方法是正确的。 但是你需要更新motionLayout.updateState(R.id.end, this) 尤其是在当前的过渡时期。 您可能还需要 requestlayout() 。