//直接在子组件中
1、WindowManager wm = (WindowManager) getContext()
.getSystemService(Context.WINDOW_SERVICE);
//目前版本已经不建议使用了,建议使用下面的方式
int width = wm.getDefaultDisplay().getWidth();
int height = wm.getDefaultDisplay().getHeight();
获取文字的宽度和高度
//1. 返回包围串的最小的一个rect区域
Paint p = new Paint();
Rect rect = new Rect();
p.getTextBounds(str,0,1,rect);
w = rect.getWidth();
h = rect.getHeight();
//2. 直接获得文字的宽度
String displayText = “Hello World!”;
float textWidth = p.measureText(displayText);