


public class AndroidsCastleActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new MyView(this));
}
class MyView extends View {
public MyView(Context context) {
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.argb(255, 255, 0, 0));//赤セット
canvas.drawCircle(50, 50, 50, paint);//円描画
//グラデーション情報を作成(0,100)から(240,200)に向けて緑→黄色でグラデーション
Shader s = new LinearGradient(0, 100, 240, 200, Color.GREEN, Color.YELLOW, Shader.TileMode.CLAMP);
paint.setShader(s);//グラデーションをセット
canvas.drawOval(new RectF(0.0f, 100.0f, 240.0f, 200.0f), paint);//楕円描画
}
}
}

Portions of this page are modifications
based on work created and shared by Google and used according to terms
described in the Creative Commons 3.0 Attribution License.
- Remical Soft -