MotionLayout motionLayout = findViewById(R.id.motionLayout);
TypedArray typedArray = motionLayout.getContext().obtainStyledAttributes(attrs, R.styleable.CustomMotionLayout);
String methodName = typedArray.getString(R.styleable.CustomMotionLayout_methodName);
typedArray.recycle();
这样就可以获取到在layout文件中定义的methodName值了。