安卓记事本代码(基于安卓的记事本的设计与实现)
admin 发布:2022-12-19 19:28 169
本篇文章给大家谈谈安卓记事本代码,以及基于安卓的记事本的设计与实现对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
- 1、安卓手机的 记事本程序 可以在电脑上编辑记事本然后考到手机中的存放目录中
- 2、怎么做一个android记事本app
- 3、在安卓手机上网页源码如何用??
- 4、android开发中如何实现手写输入的记事本
- 5、爱心代码安卓手机怎么用
- 6、安卓手机的系统记事本具体是在哪个文件夹?
安卓手机的 记事本程序 可以在电脑上编辑记事本然后考到手机中的存放目录中
电脑手机同步的记事软件可以选择敬业签云便签:
云便签有手机版和电脑版,手机和电脑支持同步记事内容。
通过手机版完成记事内容的创建后,打开电脑可同步查看与编辑。
反之通过电脑完成编辑修改后,登录手机版记事内容同步更新。
怎么做一个android记事本app
做app要先选择开发工具和语言,一般来说用android-studio 或eclipse都可以,然后选择开发语言,有java和c++,java比较容易学习,比c++简单一些。然后就可以开始编码了,编写完代码编译就可以生成apk文件,放到android手机安装运行。
在安卓手机上网页源码如何用??
操作方法如下:
1、首先打开手机,找到并点击进入设置,如下图所示。
2、然后在打开的设置页面中,点击进入更多设置,如下图所示。
3、接着在打开的页面中,点击进入关于手机,如下图所示。
4、然后在打开的页面中,点击进入版本信息,如下图所示。
5、最后在打开的页面中,看到Android版本后方的数值即为版本信息,如下图所示就完成了。
android开发中如何实现手写输入的记事本
实现手写功能的主要步骤:
1. 自定义两个View,一个是TouchView,用于在上面画图,另一个是EditText,用于将手写的字显示在其中,并且,要将两个自定义View通过FrameLayout帧式布局重叠在起,以实现全屏手写的功能。
2 在TouchView中实现写字,并截取画布中的字以Bitmap保存。
3. 设置定时器,利用handle更新界面。
下面是实现的细节:
1. 手写的界面设计:
如上图所示,和上节的画板界面一致,底部分选项菜单栏,有5个选项,分别是调整画笔大小,画笔颜色,撤销,恢复,以及清空,对于这些功能,之后几节再实现。
布局文件activity_handwrite.xml
!--?xml version=1.0 encoding=utf-8?--
relativelayout android:background="@android:color/white" android:layout_height="match_parent" android:layout_width="match_parent" xmlns:android=""imageview android:layout_above="@+id/paintBottomMenu" android:layout_height="wrap_content" android:layout_width="match_parent" android:src="@drawable/line"
/imageview/relativelayout
可以看出,里面有两个自定义view,并且通过FrameLayout重叠在一起。
先来看com.example.notes.LineEditText,这个其实和添加记事中的界面一样,就是自定义EditText,并且在字的下面画一条线。
LineEditText.java
public class LineEditText extends EditText {
private Rect mRect;
private Paint mPaint;
public LineEditText(Context context, AttributeSet attrs) {
// TODO Auto-generated constructor stub
super(context,attrs);
mRect = new Rect();
mPaint = new Paint();
mPaint.setColor(Color.GRAY);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//得到EditText的总行数
int lineCount = getLineCount();
Rect r = mRect;
Paint p = mPaint;
//为每一行设置格式
for(int i = 0; i lineCount;i++){
//取得每一行的基准Y坐标,并将每一行的界限值写到r中
int baseline = getLineBounds(i, r);
//设置每一行的文字带下划线
canvas.drawLine(r.left, baseline+20, r.right, baseline+20, p);
}
}
}
另一个就是com.example.notes.TouchView,实现了绘制,及定时更新界面的功能,具体看代码
TouchView.java
public class TouchView extends View {
private Bitmap mBitmap,myBitmap;
private Canvas mCanvas;
private Path mPath;
private Paint mBitmapPaint;
private Paint mPaint;
private Handler bitmapHandler;
GetCutBitmapLocation getCutBitmapLocation;
private Timer timer;
DisplayMetrics dm;
private int w,h;
public TouchView(Context context) {
super(context);
dm = new DisplayMetrics();
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm);
w = dm.widthPixels;
h = dm.heightPixels;
initPaint();
}
public TouchView(Context context, AttributeSet attrs) {
super(context,attrs);
dm = new DisplayMetrics();
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm);
w = dm.widthPixels;
h = dm.heightPixels;
initPaint();
}
//设置handler
public void setHandler(Handler mBitmapHandler){
bitmapHandler = mBitmapHandler;
}
//初始化画笔,画布
private void initPaint(){
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setColor(0xFF00FF00);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(15);
getCutBitmapLocation = new GetCutBitmapLocation();
//画布大小
mBitmap = Bitmap.createBitmap(w, h,
Bitmap.Config.ARGB_8888);
mCanvas = new Canvas(mBitmap); //所有mCanvas画的东西都被保存在了mBitmap中
mCanvas.drawColor(Color.TRANSPARENT);
mPath = new Path();
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
timer = new Timer(true);
}
/**
* 处理屏幕显示
*/
Handler handler = new Handler(){
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
myBitmap = getCutBitmap(mBitmap);
Message message = new Message();
message.what=1;
Bundle bundle = new Bundle();;
bundle.putParcelable(bitmap,myBitmap);
message.setData(bundle);
bitmapHandler.sendMessage(message);
RefershBitmap();
break;
}
super.handleMessage(msg);
}
};
/**
* 发送消息给handler更新ACTIVITY
*/
TimerTask task = new TimerTask() {
public void run() {
Message message = new Message();
message.what=1;
Log.i(线程, 来了);
handler.sendMessage(message);
}
};
//切割画布中的字并返回
public Bitmap getCutBitmap(Bitmap mBitmap){
//得到手写字的四周位置,并向外延伸10px
float cutLeft = getCutBitmapLocation.getCutLeft() - 10;
float cutTop = getCutBitmapLocation.getCutTop() - 10;
float cutRight = getCutBitmapLocation.getCutRight() + 10;
float cutBottom = getCutBitmapLocation.getCutBottom() + 10;
cutLeft = (0 cutLeft ? 0 : cutLeft);
cutTop = (0 cutTop ? 0 : cutTop);
cutRight = (mBitmap.getWidth() cutRight ? mBitmap.getWidth() : cutRight);
cutBottom = (mBitmap.getHeight() cutBottom ? mBitmap.getHeight() : cutBottom);
//取得手写的的高度和宽度
float cutWidth = cutRight - cutLeft;
float cutHeight = cutBottom - cutTop;
Bitmap cutBitmap = Bitmap.createBitmap(mBitmap, (int)cutLeft, (int)cutTop, (int)cutWidth, (int)cutHeight);
if (myBitmap!=null ) {
myBitmap.recycle();
myBitmap= null;
}
return cutBitmap;
}
//刷新画布
private void RefershBitmap(){
initPaint();
invalidate();
if(task != null)
task.cancel();
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint); //显示旧的画布
canvas.drawPath(mPath, mPaint); //画最后的path
}
private float mX, mY;
private static final float TOUCH_TOLERANCE = 4;
//手按下时
private void touch_start(float x, float y) {
mPath.reset();//清空path
mPath.moveTo(x, y);
mX = x;
mY = y;
if(task != null)
task.cancel();//取消之前的任务
task = new TimerTask() {
@Override
public void run() {
Message message = new Message();
message.what=1;
Log.i(线程, 来了);
handler.sendMessage(message);
}
};
getCutBitmapLocation.setCutLeftAndRight(mX,mY);
}
//手移动时
private void touch_move(float x, float y) {
float dx = Math.abs(x - mX);
float dy = Math.abs(y - mY);
if (dx = TOUCH_TOLERANCE || dy = TOUCH_TOLERANCE) {
mPath.quadTo(mX, mY, x, y);
// mPath.quadTo(mX, mY, (x + mX)/2, (y + mY)/2);//源代码是这样写的,可是我没有弄明白,为什么要这样?
mX = x;
mY = y;
if(task != null)
task.cancel();//取消之前的任务
task = new TimerTask() {
@Override
public void run() {
Message message = new Message();
message.what=1;
Log.i(线程, 来了);
handler.sendMessage(message);
}
};
getCutBitmapLocation.setCutLeftAndRight(mX,mY);
}
}
//手抬起时
private void touch_up() {
//mPath.lineTo(mX, mY);
mCanvas.drawPath(mPath, mPaint);
mPath.reset();
if (timer!=null) {
if (task!=null) {
task.cancel();
task = new TimerTask() {
public void run() {
Message message = new Message();
message.what = 1;
handler.sendMessage(message);
}
};
timer.schedule(task, 1000, 1000); //2200秒后发送消息给handler更新Activity
}
}else {
timer = new Timer(true);
timer.schedule(task, 1000, 1000); //2200秒后发送消息给handler更新Activity
}
}
//处理界面事件
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
touch_start(x, y);
invalidate(); //刷新
break;
case MotionEvent.ACTION_MOVE:
touch_move(x, y);
invalidate();
break;
case MotionEvent.ACTION_UP:
touch_up();
invalidate();
break;
}
return true;
}
}
这里面的难点就是利用TimerTask和Handle来更新界面显示,需要在onTouchEvent的三个事件中都要通过handle发送消息来更新显示界面。
接下来就是在activity里通过handle来得到绘制的字,并添加在editText中。
关于配置底部菜单,以及顶部标题栏,这里不再赘述,直接如何将绘制的字得到,并添加在edittext中:
得到绘制字体的Bitmap
//处理界面
Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
Bundle bundle = new Bundle();
bundle = msg.getData();
Bitmap myBitmap = bundle.getParcelable(bitmap);
InsertToEditText(myBitmap);
}
};
其中myBitmap就是取得的手写字,保存在Bitmap中, InsertToEditText(myBitmap);是将该图片添加在edittext中,具体如下:
?
1
private LineEditText et_handwrite;
?
1
et_handwrite = (LineEditText)findViewById(R.id.et_handwrite);
//将手写字插入到EditText中
private void InsertToEditText(Bitmap mBitmap){
int imgWidth = mBitmap.getWidth();
int imgHeight = mBitmap.getHeight();
//缩放比例
float scaleW = (float) (80f/imgWidth);
float scaleH = (float) (100f/imgHeight);
Matrix mx = new Matrix();
//对原图片进行缩放
mx.postScale(scaleW, scaleH);
mBitmap = Bitmap.createBitmap(mBitmap, 0, 0, imgWidth, imgHeight, mx, true);
//将手写的字插入到edittext中
SpannableString ss = new SpannableString(1);
ImageSpan span = new ImageSpan(mBitmap, ImageSpan.ALIGN_BOTTOM);
ss.setSpan(span, 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
et_handwrite.append(ss);
}
爱心代码安卓手机怎么用
爱心代码安卓手机我们可以进行设置一下即可。
1、首先新建一个记事本文件,双击打开。
2、打开记事本文件之后,输入一些简单的html代码。输入之后,保存文件。
3、再次点击记事本文件,按下键盘上的F2键进行重命名。将后面的txt改为html,然后确定更改。
4、更改完成后,再次打开备忘录爱心代码文件,就可以看到刚才生成的链接了。
安卓手机的系统记事本具体是在哪个文件夹?
手机是不自带记事本应用的,只能通过HTML查看器查看文本文档。
如果你只是为了编辑文档用,那么可以下载一个WPS应用(大部分手机自带),效果比记事本好多了。如果只是为了用文本文档的形式打开并编辑文件,那么还得去应用商店自行下载文档编辑应用到手机。
扩展资料:
记事本指的是Windows操作系统附带的一个简单的文本编辑、浏览软件notepad.exe。
(不过在Windows 9x和windows XP中是不同的两个版本,不能互换。)
记事本只能处理纯文本文件,但是,由于多种格式源代码都是纯文本的,所以记事本也就成为了使用最多的源代码编辑器。
参考资料:记事本
关于安卓记事本代码和基于安卓的记事本的设计与实现的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
- 上一篇:微博源代码(微博源代码python)
- 下一篇:全屏相册代码(全屏相册代码大全)
相关推荐
- 04-26vb锁定任务管理器代码(vb锁定任务管理器代码是多少)[20240426更新]
- 04-26飞行代码包(飞机飞行代码)[20240426更新]
- 04-26免费发布网站代码(免费发布网站代码大全)[20240426更新]
- 04-26css点赞动画效果代码(html点赞动画)[20240426更新]
- 04-26android下载音乐代码(音乐播放器的Android源码)[20240426更新]
- 04-26网页设计完整代码(简单的网页设计代码案例)[20240426更新]
- 04-26轮播简易代码(轮播图源代码)[20240426更新]
- 04-26jqueryphp会员权限代码的简单介绍[20240426更新]
- 04-26js时间弹窗代码(js中时间)[20240426更新]
- 04-26关于asp在线投票系统代码的信息[20240426更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接