• 自定义控件TextView


    public class defineTextView extends TextView {
        
        Context context;
    public defineTextView(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
            // TODO Auto-generated constructor stub
            this.context=context;
        }
        public defineTextView(Context context, AttributeSet attrs) {
            super(context, attrs);
            // TODO Auto-generated constructor stub
            this.context=context;
        }
        public defineTextView(Context context) {
            super(context);    
            this.context=context;
        }
        @Override
        protected void onDraw(Canvas canvas) {
            // TODO Auto-generated method stub
                Drawable[] drawable=getCompoundDrawables();
                int drawablewidth=drawable[0].getIntrinsicWidth();
                float textwidth=getPaint().measureText(getText().toString());
                int drawablepadding=getCompoundDrawablePadding();
                int bodywidth=(int) (drawablepadding+textwidth+drawablewidth);
                canvas.translate((getWidth()-bodywidth)/2, 0);
                canvas.drawLine(0, getHeight(), getWidth(), getHeight(), getPaint());
            super.onDraw(canvas);
        }
        @Override
        public void setTextSize(float size) {
            
            super.setTextSize(size);
        }
        
  • 相关阅读:
    在springmvc中,什么是逻辑视图?什么是物理视图?
    docker2
    docker1
    HTTP Service 中篇
    HTTP Service 上篇
    Centos7 fstab盘符挂载硬盘导致重启系统失败解决办法
    vsphere网络
    LVS的工作原理认识
    数字转换
    对def函数的参数认识
  • 原文地址:https://www.cnblogs.com/androidxufeng/p/3654911.html
Copyright © 2020-2023  润新知