懒癌杂句

1,强制亮屏

代码:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

xml:

2.toast居中显示

public static void showToast(Context context, int contentId)
{
   Toast toast = Toast.makeText(context, contentId, Toast.LENGTH_SHORT);
   toast.setGravity(Gravity.CENTER, 0, 0);
   toast.show();
}

你可能感兴趣的:(Android,基础)