0

when i was searching the android source code, i have found something i can not understand or bear. you can see all onSetLayoutParams in the 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 is proected, yet View.setLayoutParams cast its parent to a ViewGroup, then call ViewGroup's onSetLayoutParams. i don not think this is right in java, but all android seems running very well.

sorry for my poor english.

Rishi Paul
  • 936
  • 2
  • 8
  • 25
Zion
  • 13
  • 4

1 Answers1

0

somehow i found my answer from this page: In Java, difference between default, public, protected, and private

Java protected seems making the method not visible to classes out of this package, within the same package, its a public method.

Community
  • 1
  • 1
Zion
  • 13
  • 4