首页 新闻 赞助 找找看

使用 android.graphics绘画,首先绘制一个矩形图案,然后绘制一串字符串显示在矩形图案的正中间

0
[已关闭问题] 关闭于 2013-12-12 14:33

使用 android.graphics绘画,首先绘制一个矩形图案,然后绘制一串字符串显示在矩形图案的正中间,

                                // 圆角矩形
                RectF rectf = new RectF(topPlaceX, topPlaceY, bottomPlaceX,
                        bottomPlaceY);
                float roundPx = sizeY / 2;
                canvas.drawRoundRect(rectf, roundPx, roundPx, paint);    
//文字
                Paint textpaint = new Paint();
                /* 去锯齿 */
                textpaint.setAntiAlias(true);
                textpaint.setColor(Color.parseColor("#000000"));
                textpaint.setTextSize(16);
//x坐标居中
                textpaint.setTextAlign(Paint.Align.CENTER);
                canvas.drawText("show", bottomPlaceX
                        - sizeX / 2, bottomPlaceY
                        - "sizeY/ 3, textpaint);

这是我写的,X坐标能居中,Y坐标一直不懂怎么居中

い〇8▪16℡的主页 い〇8▪16℡ | 初学一级 | 园豆:181
提问于:2013-12-02 16:18
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册