android里能给文字设边框么 请教系统有没有提供相关接口。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 没有,可以自己写一个继承TextView的类public class BorderTextView extends TextView { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); // 将边框设为黑色 paint.setColor(android.graphics.Color.BLACK); // 画TextView的4个边 canvas.drawLine(0, 0, this.getWidth(), 0, paint);//上 canvas.drawLine(0, 0, 0, this.getHeight(), paint);//左 canvas.drawLine(this.getWidth() - 1, 0, this.getWidth(), this.getHeight(), paint);//右 canvas.drawLine(0, this.getHeight() - 1, this.getWidth(), this.getHeight(), paint);//下 } public BorderTextView(Context context, AttributeSet attrs) { super(context, attrs); } @Override public void setLayoutParams(LayoutParams params) { if(Tab.display.getWidth() == 480) { params.width = (Tab.display.getWidth() - 32) / 4; params.height = 40; } else if(Tab.display.getWidth() == 240){ params.width = (Tab.display.getWidth() - 16) / 4; params.height = 20; } else if(Tab.display.getWidth() == 640) { params.width = (Tab.display.getWidth() - 40) / 4; params.height = 45; } else if(Tab.display.getWidth() == 320) { params.width = (Tab.display.getWidth() - 20) / 4; params.height = 30; } else { params.width = (Tab.display.getWidth() - 32) / 4; params.height = 40; } super.setLayoutParams(params); }} Typeface这个类对你可能有帮助 光靠Typeface里的功能还实现不了 SpannableString.或者用背景图骗人。 请问哪个span实现了字体边框效果的? 我也是在找给TextView设置边框的方式,不能像web开发那样,直接表格布局设置边框,Android有点纠结啊 求助!实时媒体播放器功能 求帮我看看这段jni代码哪里不对。 返回退出程序怎么写代码监听 Dmtracedump无法生成调用图 聊天工具发表情在android上具体怎么实现的 SharedPreferences存储时报错? 在线请求大神帮助 请好心人发一个旧版本的android sdk 【求问】有关菜单.....Android3.0以后和以前不同如何兼容? 几十行Java代码轻松Android平台的视频开发 Android 主界面背景颜色怎么改变? 新手求指教
public class BorderTextView extends TextView {
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
// 将边框设为黑色
paint.setColor(android.graphics.Color.BLACK);
// 画TextView的4个边
canvas.drawLine(0, 0, this.getWidth(), 0, paint);//上
canvas.drawLine(0, 0, 0, this.getHeight(), paint);//左
canvas.drawLine(this.getWidth() - 1, 0, this.getWidth(), this.getHeight(), paint);//右
canvas.drawLine(0, this.getHeight() - 1, this.getWidth(), this.getHeight(), paint);//下
} public BorderTextView(Context context, AttributeSet attrs) {
super(context, attrs);
} @Override
public void setLayoutParams(LayoutParams params) {
if(Tab.display.getWidth() == 480) {
params.width = (Tab.display.getWidth() - 32) / 4;
params.height = 40;
} else if(Tab.display.getWidth() == 240){
params.width = (Tab.display.getWidth() - 16) / 4;
params.height = 20;
} else if(Tab.display.getWidth() == 640) {
params.width = (Tab.display.getWidth() - 40) / 4;
params.height = 45;
} else if(Tab.display.getWidth() == 320) {
params.width = (Tab.display.getWidth() - 20) / 4;
params.height = 30;
} else {
params.width = (Tab.display.getWidth() - 32) / 4;
params.height = 40;
}
super.setLayoutParams(params);
}
}
光靠Typeface里的功能还实现不了
或者用背景图骗人。
请问哪个span实现了字体边框效果的?