一、自己定义的myView里面内容过大,一个屏幕根本显示不了,想通过加入滚动条来实现他的滚动,可是在我增加了滚动条之后(网上查,只能通过ScrollView来加滚动条),myView里面的内容就显示不了了,我想知道这是为什么?(看到的效果是,我的内容显示了一下,就没有了)
    二、在重写的 onMeasure()方法中, 我加入了一句 System.out.println("测试") 打印了两次,有谁能告诉一下我,这个方法是怎么被调用的。

解决方案 »

  1.   

    那你滚动的时候看看view的ondraw走了几次
      

  2.   

    在你的myView中加上下面的代码
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { setMeasuredDimension(800, 2000); }
    onMeasure 是view的函数,你自己再看下参数吧,肯定可以的 
      

  3.   

    这里我自己搞明白了 那个onDraw()方法中,是不能改变属性的, 比如 
    public myClass extendx View{
        private int i = 0;
        private String name = "zhangkai"
        ……
    }
    只能改变方法中的变量对 属性i 和属性name 是没有起作用的   (这里只是打比方)  
    Android 才入门 说的有错误 还请多多指教 !
      

  4.   


    楼主没看懂什么意思?我的页遇到和你一样的问题了?
    能不能看看你怎么给自定义的View加的ScrollView,还有我将自定义的View加入ScrollView后也是不显示!望指导!谢谢
      

  5.   

    关于那个滚动条的 自己用ScrollBy scrollTo方法去调整 滚动条只是一个指示 自己在画指示就可以了
      

  6.   


    <LinearLayout
            android:id="@+id/next_layout"
            android:layout_width="fill_parent"
            android:layout_height="0.0dp"
            android:layout_margin="3dp"
            android:layout_weight="2"
            android:background="@android:color/darker_gray"
            android:orientation="vertical" >        <GridView
                android:id="@+id/gridview_header"
                android:layout_width="wrap_content"
                android:layout_height="0.0dp"
                android:layout_weight="1"
                android:gravity="center"
                android:numColumns="6" >
            </GridView>        <ScrollView
                android:id="@+id/scrollView"
                android:layout_width="wrap_content"
                android:layout_height="0.0dp"
                android:layout_weight="3" 
                android:fillViewport="true">
                <com.rj.weather.MyView
                    android:id="@+id/data"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
            </ScrollView>        <GridView
                android:id="@+id/gridview_footer"
                android:layout_width="wrap_content"
                android:layout_height="0.0dp"
                android:layout_weight="1"
                android:gravity="center"
                android:numColumns="6" >
            </GridView>
        </LinearLayout>楼主,我的问题基本一致,嵌套后滚动不了啊!感谢了