1、获取屏幕宽度
屏幕宽度可以直接在activity的onCreate中获取,但控件宽度却不能,获取单位为px像素
DisplayMetrics dm = getResources().getDisplayMetrics();
int screenwidth = dm.widthPixels;
int screenheight = dm.heightPixels;
2、获取控件宽高及位置
在activity的onWindowFocusChanged(boolean hasFocous)中获取
@Override
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
int[] location = new int[2]; //location[0] 为x坐标 location[1]为y