小编Kri*_*jan的帖子

Android:在Scrollview中绘制画布

我在为Android编程时非常新.我的应用程序是来自开发者android网站上的api demos的示例应用程序.当我更改该样本绘图中的参数时,它会变大.该绘图需要在滚动视图中显示(不需要缩小以适应屏幕).这是我使用的代码:

DrawPoints.java

    public class DrawPoints extends myActivity {


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.routes); 

    }

    public static class SampleView extends View {
        private Paint   mPaint = new Paint();
        private float[] mPts;

       /*here comes declaration of parametars



        private void buildPoints() {

        /*here comes some coding*/

            }
        }

        public SampleView(Context context, AttributeSet attributeset) {
            super(context, attributeSet);

            buildPoints();
        }

        @Override 
        protected void onDraw(Canvas canvas) {
            Paint paint = mPaint;

            //here also comes code
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是xml代码:

routes.xml

<?xml version="1.0" …
Run Code Online (Sandbox Code Playgroud)

android scrollview drawing2d

6
推荐指数
2
解决办法
9609
查看次数

标签 统计

android ×1

drawing2d ×1

scrollview ×1