视频:善知堂Android http://www.verycd.com/topics/2915940/
第三季
第一集:游戏演示和理念
用photoshop 其实也不难。
第二集 绘图1
1.在配置中加入命名空间
xmlns:android="http://schemas.android.com/apk/res/android"
2.设置button的属性
//设置文本颜色 button.setTextColor(Color.RED);
3.将button上画圆形
class MyButton extends Button { // 这个是继承必须写的,带参构造器,所以要重写 public MyButton(Context context) { super(context); // TODO Auto-generated constructor stub } // 在按钮中画图 @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); // 画笔 Paint paint = new Paint(); paint.setColor(Color.GREEN); canvas.drawCircle(30, 30, 30, paint); } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MyButton my = new MyButton(this); LinearLayout lay = new LinearLayout(this); lay.addView(my); setContentView(lay); }
4.使用画图写游戏的建议继承View
class GameView extends View { private Paint paint = null; public GameView(Context context) { super(context); paint = new Paint(); } @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); paint.setColor(Color.RED); paint.setStrokeWidth(5);//画笔粗 canvas.drawLine(0, 0, 100, 111, paint); } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); GameView my = new GameView(this); LinearLayout lay = new LinearLayout(this); lay.addView(my); setContentView(lay); }
第三天早 结束