1.得到屏幕宽高+在代码里设置应用的宽高
[java] view
plaincopy
- // 屏幕矩形
- mRect =new Rect(0,0,this.getWindowManager().getDefaultDisplay().getWidth(),
- this.getWindowManager().getDefaultDisplay().getHeight());
- FrameLayout lfl = (FrameLayout)findViewById(R.id.FrameLayout);
- FrameLayout.LayoutParams lFLpp = (FrameLayout.LayoutParams)lfl.getLayoutParams();
- lFLpp.width = mRect.width();
- lFLpp.height = mRect.height();
- lfl.setLayoutParams(lFLpp);
2.设置无标题,全屏,横屏
[java] view
plaincopy
- requestWindowFeature(Window.FEATURE_NO_TITLE); // 无标题
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN); // 全屏
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // 横屏
3.以String形式返回当前时间
[java] view
plaincopy
- private String getTimeReturnString() {
- Time m_Time = new Time("GMT+8");
- m_Time.setToNow();
- return String.format("%dH%dS%dM",m_Time.hour,m_Time.minute,m_Time.second);
- }
4.SurfaceView设置背景透明
[java] view
plaincopy
- this.setZOrderOnTop(true);
- mSurfaceHolder.setFormat(PixelFormat.TRANSPARENT);
5.类似1的另一种实现
[java] view
plaincopy
- mWindow = getWindow();
- WindowManager.LayoutParams lLayoutParams = mWindow.getAttributes();
- lLayoutParams.x = paX;
- lLayoutParams.y = paY;
- lLayoutParams.width = paWidth;
- lLayoutParams.height = paHeight;
- lLayoutParams.dimAmount = 0f; // 背景不变暗
- mWindow.setAttributes(lLayoutParams);
5.通知栏的坐标变化动画计算方式。看了下其实是加速度的计算方法,不过不知道我自已写的运行效果不理想,没有系统的平滑。
[java] view
plaincopy
- void incrementAnim() {
- long now = SystemClock.uptimeMillis();
- float t = ((float)(now - mAnimLastTime)) / 1000; // ms -> s
- final float x = mAnimX;
- final float v = mAnimVel; // px/s
- final float a = mAnimAccel; // px/s/s
- mAnimX = x + (v*t) + (0.5f*a*t*t); // px
- mAnimVel = v + (a*t); // px/s
- mAnimLastTime = now; // ms
- }
时间: 2024-11-03 01:42:01