public class Test extends View{ public Test(Context context) {
super(context);
int i = mMeasuredWidth;//编译器不通过。
}}
mMeasuredWidth是VIEW中的protected int mMeasuredWidth;
VIEW中所有的保护变量都不能被继承的类所使用,WHY??
但是在ANDROID包中的其他类可以使用VIEW的保护变量。

解决方案 »

  1.   

    protected int mTop;
      
    protected int mBottom;protected int mScrollX;
       
    protected int mScrollY;
    打开VIEW类可以看到上面这些实例变量,都不能在继承类里用(但是android包里的继承类可以用,比如
    ScrollView里面到处用到了mScrollX和mScrollY
    我现在想实现一个类似ScrollView的类,所以继承了VIEW,但是我不能用这些PROTECTED变量
    WHY???
      

  2.   

    我知道可以用父类的GET方法,但是我想搞清楚为啥不能直接用父类的PROTECTED实例变量。
      

  3.   

     @ViewDebug.ExportedProperty
        protected int mScrollX; @ViewDebug.ExportedProperty  这个属性的 在SDK中都是看不到的
    除非你把工程放到源码 不用sdk编译