Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Monday, November 3, 2014

Graphics and Animations



Go to Mind Mup: Graphics and Animations

Graphic and Animations

  • Animation
    • TransitionDrawable: Fade 1 drawable to another drawable
      • <transition> <item> </item> <item> </item> </transition>
    • AnimationDrawable: drawable slide show
      • <animation-list> <item> </item> .... .... </animation-list>
    • Animation: Animate the size, orientation, position of a view
      • <set> alpha: fade in/out rotate translate scale <set>
  • drawables
    • Shapes (xml)
    • Images (png)
  • Canvas
    • Generic View less frequent updates
    • SurfaceView More frequent updates
      • provide a secondary thread for drawing
        • 1- SETUP
          • Acquire the surface holder getHolder()
          • Register the surface view for call backs addCallBack() These callbacks are (called usually from main thread): surfaceCreated() surfaceChanged() surfaceDestroyed()
          • Create the secondary thread
        • 2- DRAW
          • Acquire lock on CANVAS: SurfaceHolder.lockCanvas()
          • Draw: Canvas.drawBitmap()
          • Unlock the canvas, allowing android to update and display: SurfaceHolder.unlockCanvasAndPost

Sensors - Accelerometer










Accelorometer

  • 1. Get reference to a sensor manager: getSystemService(context.SENSOR_SERVICE)
  • 2. Access to a specific sensor: SensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
  • 3. Implent a sensor event listener:
    • onAccuracyChange()
    • onSensorChanged()
  • 4. registerListener()
  • 5. unregisterListener()
Go To the latest mind mup: Accelerometer