<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/save"
android:orderInCategory="100"
android:showAsAction="never"
android:title="保存涂鸦"/>
<item
android:id="@+id/clear"
android:orderInCategory="100"
android:showAsAction="never"
android:title="清除数据"/>
</menu>
Activity
/**
* 画板涂鸦
* 1.在内存中生成一张图片
* 2.为ImageView设置这张图片
* 3.设置画布,画笔
* 4.为ImageView设置监听事件
* @author 刘楠
*
* 2016-3-3下午7:28:20
*/
public class MainActivity extends Activity implements OnClickListener,
OnSeekBarChangeListener, OnTouchListener{
private static final String TAG = "MainActivity";
/*
* 进度条,用来改变画笔粗细
*/
private SeekBar seekBar;
/*
* 画笔的颜色
*/
private View red;
private View green;
private View blue;
private View yellow;
private View purple;
/*
* 画板
*/
Canvas canvas ;
/*
* 画笔
*/
Paint paint;
private ImageView ivResult;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*
* 画板要画的地方
*/
ivResult = (ImageView) findViewById(R.id.iv_result);
/*
* 进度条,用来改变画笔粗细
*/
seekBar = (SeekBar) findViewById(R.id.seekbar);
/*
* 画笔的颜色
*/
red = findViewById(R.id.red);