I'm trying to make visibility changes for a view under MotionLayout using this answer https://stackoverflow.com/a/62658424/5412554 but for me, it's not working under observe. For eg:
viewModel.messageLinkedList.observe(viewLifecycleOwner) {
binding.motionLayout.getConstraintSet(R.id.start).getConstraint(binding.deleteAllText.id).propertySet.mVisibilityMode = 1; // 1 - ignore or 0 - normal
binding.deleteAllText.visibility = View.GONE
}
If I use simply in onCreateView of fragment it works.
For eg:
binding.motionLayout.getConstraintSet(R.id.start).getConstraint(binding.deleteAllText.id).propertySet.mVisibilityMode = 1; // 1 - ignore or 0 - normal
binding.deleteAllText.visibility = View.GONE
Please help me with the correct solution.