资源简介
安卓涂鸦源码,能够实现设置画笔风格,粗细,颜色;从图库选择带涂鸦的图片,保存涂鸦后的图片,清除涂鸦操作。开发环境android4.4(API19)
代码片段和文件信息
package com.example.androidtuya;
import net.margaritov.preference.colorpicker.*;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.app.Dialog;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Paint;
public class MainActivity extends Activity
{
final int SELECT_IMAGE = 1;
private MyView touchView = null;
private boolean mAlphaSliderEnabled = false;
private boolean mHexValueEnabled = false;
private Paint mPaint;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
touchView = (MyView)findViewById(R.id.myView);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main menu);
return true;
}
public class BackgroundColorListener implements ColorPickerDialog.OnColorChangedListener
{
public void onColorChanged(int color)
{
touchView.setBitmapColor(color);
touchView.invalidate();
}
}
public class PaintColorChangedListener implements ColorPickerDialog.OnColorChangedListener
{
public void onColorChanged(int color)
{
touchView.setBitmapColor(color);
touchView.invalidate();
}
}
public boolean onOptionsItemSelected(MenuItem Item)
{
int item_id = Item.getItemId();
switch(item_id)
{
case R.id.choose:
chooseBackground();
break;
case R.id.pen:
choosePaint();
break;
case R.id.save:
touchView.saveImage();
break;
case R.id.clear:
break;
}
return true;
}
private void chooseBackground()
{
String[] itemsTo = {“选择图片““选择颜色“};
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.settitle(“选择背景“);
builder.setItems(itemsTo new DialogInterface.onclickListener() {
@Override
public void onclick(DialogInterface arg0 int arg1) {
// TODO Auto-generated method stub
if(arg1 == 0)
{
pickupLocalImage(SELECT_IMAGE);
}
if(arg1 == 1)
{
showColorDialog(null);
}
}
});
builder.create().show();
}
protected void pickupLocalImage(int return_num)
{
try {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType(“image/*“);
startActivityForResult(intentreturn_num);
} catch (Exception e)
{
e.printStackTrace();
}
}
pr
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-01-21 18:16 AndroidTuya\
文件 475 2014-01-13 22:15 AndroidTuya\.classpath
文件 847 2014-01-05 20:12 AndroidTuya\.project
目录 0 2014-01-21 18:16 AndroidTuya\.settings\
文件 111 2014-01-13 20:17 AndroidTuya\.settings\org.eclipse.core.resources.prefs
文件 177 2014-01-05 20:12 AndroidTuya\.settings\org.eclipse.jdt.core.prefs
文件 1129 2014-01-20 10:16 AndroidTuya\AndroidManifest.xm
目录 0 2014-01-05 20:12 AndroidTuya\assets\
目录 0 2014-01-21 18:16 AndroidTuya\bin\
目录 0 2014-01-21 18:16 AndroidTuya\bin\classes\
目录 0 2014-01-21 18:16 AndroidTuya\bin\classes\com\
目录 0 2014-01-21 18:16 AndroidTuya\bin\classes\com\example\
目录 0 2014-01-21 18:16 AndroidTuya\bin\classes\com\example\androidtuya\
文件 4457 2014-01-20 11:15 AndroidTuya\bin\classes\com\example\androidtuya\MainActivity$BackgroundColorListener.class
文件 4461 2014-01-20 11:15 AndroidTuya\bin\classes\com\example\androidtuya\MainActivity$PaintChangeListener.class
文件 4463 2014-01-20 11:15 AndroidTuya\bin\classes\com\example\androidtuya\MainActivity$PaintColorChangedListener.class
文件 7299 2014-01-20 11:15 AndroidTuya\bin\classes\com\example\androidtuya\MainActivity.class
文件 4590 2014-01-20 11:15 AndroidTuya\bin\classes\com\example\androidtuya\MyView$DrawPath.class
文件 8734 2014-01-20 11:15 AndroidTuya\bin\classes\com\example\androidtuya\MyView.class
文件 5438 2014-01-20 11:15 AndroidTuya\bin\classes\com\example\androidtuya\PaintDialog$ColorClickListener.class
文件 4844 2014-01-20 11:15 AndroidTuya\bin\classes\com\example\androidtuya\PaintDialog$OnPaintChangedListener.class
文件 5408 2014-01-20 11:15 AndroidTuya\bin\classes\com\example\androidtuya\PaintDialog$SeekBarListener.class
文件 5359 2014-01-20 11:15 AndroidTuya\bin\classes\com\example\androidtuya\PaintDialog$SpinnerItemSelected.class
文件 8968 2014-01-20 11:15 AndroidTuya\bin\classes\com\example\androidtuya\PaintDialog.class
目录 0 2014-01-21 18:16 AndroidTuya\bin\classes\net\
目录 0 2014-01-21 18:16 AndroidTuya\bin\classes\net\margaritov\
目录 0 2014-01-21 18:16 AndroidTuya\bin\classes\net\margaritov\preference\
目录 0 2014-01-21 18:16 AndroidTuya\bin\classes\net\margaritov\preference\colorpicker\
文件 4901 2014-01-20 11:15 AndroidTuya\bin\classes\net\margaritov\preference\colorpicker\AlphaPatternDrawable.class
文件 4743 2014-01-20 11:15 AndroidTuya\bin\classes\net\margaritov\preference\colorpicker\ColorPickerDialog$OnColorChangedListener.class
文件 10522 2014-01-20 11:15 AndroidTuya\bin\classes\net\margaritov\preference\colorpicker\ColorPickerDialog.class
............此处省略59个文件信息
评论
共有 条评论