Can we user butterknife and databinding together in a fragment?

215 Views Asked by At

I am beginner to Android and I am working on a project, where the butterknife is used, I have to set the dark theme and light theme based on a user preference. I added databinding inorder to apply to the background and the test views based on the theme change. Is it okay to have butterknife and databinding in the same class.

Could you please help clarify.

1

There are 1 best solutions below

1
Anand On

Is it okay to have butterknife and databinding in the same class.

You can use both alongside in your project.

The downside is that both butterknife and databinding will be generating boilerplate code required for you.

But databinding gives has more benefits than butterknife and much more cleaner code also. databinding is much more advanced than butterknife. For more about databinding and also some blogs making head-to-head comparison here and here.

As officially announced for Butterknife,

Attention: This tool is now deprecated. Please switch to view binding. Existing versions will continue to work, obviously, but only critical bug fixes for integration with AGP will be considered. Feature development and general bug fixes have stopped.

The better way is to slowly start to get rid of butterknife and start using databinding