bestTao
12/21/2016 - 8:31 AM

Android代码片段

Android代码片段

@Override
public void onBackPressed()
 {
    //实现Home键效果
    //super.onBackPressed();这句话一定要注掉,不然又去调用默认的back处理方式了
    Intent intent= new Intent(Intent.ACTION_MAIN);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addCategory(Intent.CATEGORY_HOME);
    startActivity(intent);
}
view.bringToFront()
ViewGroup.bringChildToFront(View child)
DisplayMetrics metrics =getResources().getDisplayMetrics();  
int width = metrics.widthPixels;  
int height = metrics.heightPixels;  
int[] locationArr = new int[2];
getLocationOnScreen(locationArr);//x=locationArr[0],y=locationArr[1]
//或者
x = getRawX();
y = getRawY();