android - why does View.setLayoutParams can call ViewGroup.onSetLayoutParams which is protected? -
when searching android source code, have found can not understand or bear. can see onsetlayoutparams in frameworks source code bellow:
./base/core/java/android/widget/toolbar.java: protected void onsetlayoutparams(view child, viewgroup.layoutparams lp) {
./base/core/java/android/widget/gridlayout.java: protected void onsetlayoutparams(view child, viewgroup.layoutparams layoutparams) {
./base/core/java/android/widget/gridlayout.java: super.onsetlayoutparams(child, layoutparams);
./base/core/java/android/view/view.java: ((viewgroup) mparent).onsetlayoutparams(this, params);
./base/core/java/android/view/viewgroup.java: protected void onsetlayoutparams(view child, layoutparams layoutparams) {
every define of onsetlayoutparams proected, yet view.setlayoutparams cast parent viewgroup, call viewgroup's onsetlayoutparams. don not think right in java, android seems running well.
sorry poor english.
somehow found answer page: in java, difference between default, public, protected, , private
java protected seems making method not visible classes out of package, within same package, public method.
Comments
Post a Comment