如果我们对 Android 视图使用私有访问修饰符有什么坏处吗?

Is there any harm if we use private access modifier for Android Views?

例如,下面的代码对吗?

private LinearLayout layout1;
private LinearLayout layout2;
private LinearLayout layout3;

不,这没有坏处。但是,如果您正在使用某种视图注入库,例如 ButterKnife,它不会让您将视图定义为 private。原因如下:

The reason that Butter Knife requires views not be private is that it actually generates code which sets the fields. The code that it generates lives in the same package as your class which is why the field must be package-private, protected, or public. If the field was private the generated code would fail to compile since it cannot access the private field.

来源:Butterknife View injection