android开发——小细节笔记
全屏去状态栏
Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
InputStream is = getResources().openRawResource(R.drawable.icon); //decode Bitmap mBitmap = BitmapFactory.decodeStream(is);
int screenWidth; int screenHeight; WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); screenWidth = display.getWidth(); screenHeight = display.getHeight();
<activity android:name=".GamePlay" android:screenOrientation="portrait"></activity>
Animation rotateAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate1);
Resources res = context.getResources();
public void onCreate() { if(this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { Log.i("info", "landscape"); } else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { Log.i("info", "portrait"); } }
Toast.makeText(testActivity.this, "click button", Toast.LENGTH_SHORT).show();
((BitmapDrawable)res.getDrawable(R.drawable.youricon)).getBitmap();