Android 开发知识 全屏幕设置及图形绘制的使用
注释很详细,不再婆婆妈妈了.....运行效果如图所示
FullScreenActivity 类源代码
[java] /**
* 作者:泰蓝特软件
* 网址:http://www.talentsoft.cn
* 邮箱:1047109942@qq.com
* QQ :1047109942
*/
package cn.talentsoft.fullscreen;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
/**
* 启动类
*/
public class FullScreenActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 隐藏android系统的状态栏
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// 隐藏应用程序的标题栏,即当前activity的标题栏
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(new FullScreenView(this));
}
}
/**
* 作者:泰蓝特软件
* 网址:http://www.talentsoft.cn
* 邮箱:1047109942@qq.com
* QQ :1047109942
*/
package cn.talentsoft.fullscreen;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
/**
* 启动类
*/
public class FullScreenActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 隐藏android系统的状态栏
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// 隐藏应用程序的标题栏,即当前activity的标题栏
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(new FullScreenView(this));
}
}
FullScreenView 类源代码
[java] /**
* 作者:泰蓝特软件
* 网址:http://www.talentsoft.cn
* 邮箱:1047109942@qq.com
* QQ :1047109942
*/
package cn.talentsoft.fullscreen;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.view.View;
/**
* 设置Activity全屏显示及简单图形绘制
*/
public class FullScreenView extends View {
// 画笔
private Paint paint;
public FullScreenView(Context context) {
super(context);
paint = new Paint();
// 消除绘图过程中产生的锯齿
paint.setAntiAlias(true);
// 设置屏幕保持开启状态
setKeepScreenOn(true);
// 设置画笔为黑色
paint.setColor(Color.BLACK);
}
public void onDraw(Canvas canvas) {
// 设置画布为白色
canvas.drawColor(Color.WHITE);
// 定义矩形
Rect rect = new Rect(20, 20, 70, 70);
// 采用画笔paint,在画布上绘制矩形
canvas.drawRect(rect, paint);
// 定义矩形,与Rect区别为精度
RectF rectF = new RectF(80f, 80f, 100f, 100f);
// 在画布上绘制矩形
canvas.drawRect(rectF, paint);
float[] points = new float[] { 50f, 120f, 30f, 200f,30f, 200f, 100f, 200f, 100f, 200f,120f, 120f,120f, 120f, 50f, 120f};
// 参数points数组形式含义为x1,y1,x2,y2.....
canvas.drawLines(points, paint);
// 设置画笔为非填充模式
paint.setStyle(Paint.Style.STROKE);
canvas.drawCircle(220, 100, 50, paint);
// 设置绘制文本的大小
paint.setTextSize(30);
canvas.drawText("www.talentsoft.cn", 10, 250, paint);
}
}
/**
* 作者:泰蓝特软件
* 网址:http://www.talentsoft.cn
* 邮箱:1047109942@qq.com
* QQ :1047109942
*/
package cn.talentsoft.fullscreen;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.view.View;
/**
* 设置Activity全屏显示及简单图形绘制
*/
public class FullScreenView extends View {
// 画笔
private Paint paint;
public FullScreenView(Context context) {
super(context);
paint = new Paint();
// 消除绘图过程中产生的锯齿
paint.setAntiAlias(true);
// 设置屏幕保持开启状态
setKeepScreenOn(true);
// 设置画笔为黑色
paint.setColor(Color.BLACK);
}
public void onDraw(Canvas canvas) {
// 设置画布为白色
canvas.drawColor(Color.WHITE);
// 定义矩形
Rect rect = new Rect(20, 20, 70, 70);
// 采用画笔paint,在画布上绘制矩形
canvas.drawRect(rect, paint);
// 定义矩形,与Rect区别为精度
RectF rectF = new RectF(80
补充:移动开发 , Android ,