导航:首页 > 操作系统 > android去锯齿

android去锯齿

发布时间:2024-11-11 16:25:57

android设计中如何随机生成一个方格界面,类似于棋盘那种,用什么函数实现

public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

MyView mv = new MyView(this);
setContentView(mv);
}
public class MyView extends View {
MyView(Context context) {
super(context);
}
private int startX = 0; //起始位置
private int startY = 0;
private int GRID_WIDTH = 30; //格子的高和宽
private int GRID_NUM = 12;//要画的棋盘中的线数
Paint paint = new Paint();//定义画笔
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
paint.setColor(0xffff0000);//设置画笔的颜色
paint.setAntiAlias(true);//去锯齿

for(int i=0;i<GRID_NUM;i++)
{
//画横线
canvas.drawLine(startX, startY+i*GRID_WIDTH,startX+(GRID_NUM-1)*GRID_WIDTH , startY+i*GRID_WIDTH, paint);
//画纵线
canvas.drawLine(startX+i*GRID_WIDTH, startY,startX+i*GRID_WIDTH , startY+(GRID_NUM-1)*GRID_WIDTH, paint);
}
}

}
}

我已经尽力来……

❷ android 怎么画2层圆环

Android绘制两层圆环,可以使用自定义View,继承View,重写里面的Ondraw方法,花两个同心圆,示例如下:

java">packagecom.cn.myvn;

importandroid.content.Context;
importandroid.graphics.Canvas;
importandroid.graphics.Paint;
importandroid.util.AttributeSet;
importandroid.view.View;

{

privatefinalPaintpaint;
privatefinalContextcontext;

publicRingView(Contextcontext){

//TODOAuto-generatedconstructorstub
this(context,null);
}

publicRingView(Contextcontext,AttributeSetattrs){
super(context,attrs);
//TODOAuto-generatedconstructorstub
this.context=context;
this.paint=newPaint();
this.paint.setAntiAlias(true);//消除锯齿
this.paint.setStyle(Paint.Style.STROKE);//绘制空心圆
}

@Override
protectedvoidonDraw(Canvascanvas){
//TODOAuto-generatedmethodstub
intcenter=getWidth()/2;
intinnerCircle=dip2px(context,83);//设置内圆半径
intringWidth=dip2px(context,5);//设置圆环宽度

//绘制内圆
this.paint.setARGB(155,167,190,206);
this.paint.setStrokeWidth(2);
canvas.drawCircle(center,center,innerCircle,this.paint);

//绘制圆环
this.paint.setARGB(255,212,225,233);
this.paint.setStrokeWidth(ringWidth);
canvas.drawCircle(center,center,innerCircle+1+ringWidth/2,this.paint);

//绘制外圆
this.paint.setARGB(155,167,190,206);
this.paint.setStrokeWidth(2);
canvas.drawCircle(center,center,innerCircle+ringWidth,this.paint);

super.onDraw(canvas);
}
}

❸ Android 如何在数字上加一条横线,求代码,哪位大牛帮下忙啊

这要要在代码中设置
textView.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下划线
textView.getPaint().setAntiAlias(true);//抗锯齿
textview.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG); //中划线
setFlags(Paint. STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG); // 设置中划线并加清晰
textView.getPaint().setFlags(0); // 取消设置的的划线

阅读全文

与android去锯齿相关的资料

热点内容
android框架代码 浏览:668
python语法分析器 浏览:732
怎么制作彩票网站源码 浏览:872
java模糊查找 浏览:387
闲置硬盘搭建私有云服务器 浏览:725
kswapdlinux 浏览:235
关机小命令 浏览:862
压缩机怎么接管 浏览:611
怎样识别水货程序员 浏览:705
单片机秒表c程序 浏览:254
香港文件加密系统排行榜 浏览:473
如何设置电脑连接到服务器 浏览:890
安卓手机怎么下载僵尸黎明 浏览:763
app兑换码怎么购买 浏览:253
钱多多app赚钱软件怎么提现 浏览:687
ftp上传数据命令 浏览:393
单片机c语言程序100例pdf 浏览:875
nginxphp路径配置文件 浏览:381
安卓加密dns地址 浏览:870
空调压缩机好多钱 浏览:729