java - Drawing & creating the canvas on the android screen -
The code will run through an array. If the character is seen in the 'X' array, then it will be painted on the respective location on the screen.
The problem is that the color is not really being dragged on the screen Some of the Android websites talked about the need for canvas, bitmap etc. e.t.c.
My question: What do I need to do to show the color with a direct method on the screen? method To view your code via XML or through code, use it as a fully qualified name: XML:
package com.example.routedrawingtest; Import android App Import Android.graphics. Canvas; Import android.graphics.color; Import android.graphics.Point; Importroid.os.Bundle; Import android.view.Display; Import android.graphics.Paint; Import android.view.View; Public classroom enhances main activity activity {@ Override Protected Zero (Bundled Saved Instance) {super.onCreate (savedInstanceState); SetContentView (R.layout.activity_main); } Float scale_x; Float scale_y; Public Zero Main (string [] Args) {@SuppressWarnings ("unused") display display = getWindowManager (). GetDefaultDisplay (); Point size = new point (); Int screen_width = size.x; Int screen_height = size.y; Scale_x = Screen_width / 125; Scale_y = screen_hite / 100; } Scared public nil (canvas canvas) {int i; Paint paint = new paint (); Paint.setColor (Color.RED); Paint.setStrokeWidth (10); Int j; For (i = 0; i & lt; 125; i ++) (j = 0; j & lt; 100; j ++) if (charmap [i] [j] == 'x') canvas .drawRect (i * scale_x, j * scale_y, scale_x, scale_y, paint); }}
onDraw is not called by one The
Activity is what you want, you have to expand the class to see and implement the method there. As long as you add parents to see, you learn more about it, you have to give it a clear shape like
fill_parent , or it will not appear on screen. For example:
Public square drawer expands see {paint paint = new paint (); Public Drawer () {paint.setStyle (style.strack); Paint.setStrokeColor (Color.BlUE); // etc ...} Public Utility Panda (Canvas Canvas) {for (i = 0; i & lt; 125; i ++) for (j = 0; j & lt; 100; j ++) if ( CharMap [i] [j] == 'X') canvas.drawRect (i * scale_x, j * scale_y, scale_x, scale_y, paint); }}
& lt; Com.example.comp Driver Android: layout_width = "fill_pant" & lt; & Lt; & Lt; & Lt; Specify a shape etc ... / & gt;
Comments
Post a Comment