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);
}