Note that there are some explanatory texts on larger screens.

plurals
  1. PODraw with a Canvas on a view, but nothing painted
    primarykey
    data
    text
    <p>I'm a beginner. I got a problem. This is an example about canvas on a view. </p> <p>A circle and text on it are supposed to be seen.</p> <p>(<a href="http://goo.gl/6ZPvQ" rel="nofollow">http://goo.gl/6ZPvQ</a>) My reputation isn't enough to get a picture.</p> <p>But Nothing happened.</p> <p>This is the view I draw canvas on. </p> <pre><code>public class TestCanvasActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new MyGraphics(this)); } } class MyGraphics extends View { private Paint cPaint,tPaint; private Path circle; private String text; @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); cPaint = new Paint(Color.GRAY); tPaint = new Paint(Color.BLACK); circle = new Path(); text = "Welcome to Android!!"; circle.addCircle(150, 150, 100, Direction.CW); canvas.drawPath(circle, cPaint); canvas.drawTextOnPath(text, circle, 0, 20, tPaint); } public MyGraphics(Context context) { super(context); // TODO Auto-generated constructor stub setBackgroundColor(R.drawable.background); } } </code></pre> <p>This is the background image code!!</p> <p>background.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;gradient android:startColor="#FFFFFF" android:endColor="#808080" android:angle="270" /&gt; &lt;/shape&gt; </code></pre> <p>Thank you!!</p> <p>I Made a low level mistake. I change <strong>cPaint = new Paint(Color.GRAY)</strong> to the next two line. It works!! </p> <pre><code> cPaint = new Paint(); cPaint.setColor(Color.WHITE); </code></pre> <p>Thank you all the same.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload