Monday, October 28, 2013

View, SurfaceView

1. What is View in Android?
Ans: A widgets like buttons and text fields. A activity uses views and fragmaents to create the user interface. View Hierarchy: Hierarchy Viewer allows you to debug and optimize your user interface. It provides a visual representation of the layout's View hierarchy (the Layout View) and a magnified inspector of the display (the Pixel Perfect View).

2. What is Surface View?
Ans: Provides a dedicated drawing surface embedded inside of a view hierarchy. You can control the format of this surface and, if you like, its size; the SurfaceView takes care of placing the surface at the correct location on the screen

3. How you Use Surface view in Android and Show me working code?
Ans: with surfaceCreated(surfaceholder) and surfaceDestroyed(surfaceholder) methods.

4. Is it possible to add any view in Android Surface View ?
Ans. yes

5. If adding view on surface view then Show one example?

Ans. Enclose your surfaceView with a FrameLayout in your xml Layout. Then add your buttons to the same FrameLayout. Make sure they are placed below the surface view so they get drawn on top of it.




6. What is media Player in android, why it’s needed?
Ans: MediaPlayer class can be used to control playback of audio/video files and streams.
Displays a video file. The VideoView class can load images from various sources (such as resources or content providers), takes care of computing its measurement from the video so that it can be used in any layout manager, and provides various display options such as scaling and tinting.

7. Can Media player UI resize? if so, show me a working code?
Ans: yes

8. What are the layouts available to create a UI-layout in .xml file?
Ans: Relative Layout, Linear Layout.Table Layout and Frame Layout.

9. Is there difference between Media player from Layout .xml file and Media player from android java code?