Many of the Android SDK’s Java packages are designed to accomplish tasks that are specific to the operating system and application framework. One of the most important for anyone who’s building games or other graphically intensive apps is android.graphics. It includes interfaces and classes for drawing arbitrary shapes on the screen.
- Many of the Android SDKs Java packages…are designed to accomplish tasks…that are specific to the Operating System…and the Application Framework.…One of the most important for anyone who's building games…or other graphically intensive applications…is "android.graphics".…From the API docs screen I'll search for that package.…The package includes classes and interfaces…for managing graphics on screen.…I'm going to give you a simple example…of drawing a basic shape on screen…that's designed as a View object.…
Because it's a View object it can be added to any layout.…In this application named "Graphics"…I've simplified my CodeRunner app.…The layout file no longer has…a TextView for logging information,…instead it just has a FrameLayout…where the TextView used to be.…A FrameLayout can contain a single View object.…It has an id of "frameLayout"…and in the MainActivity class I've declared…a field named "mContainer"…which its type is FrameLayout.…
And in the onCreate method I'm initializing that variable…by finding the object by its id…
Watch these Java tutorials to learn smarter, more efficient methods for Android app development.
- Preparing the development environment
- Packaging and running Android apps
- Optimizing Java code for Android
- Implementing event handler interfaces
- Defining custom callback methods
- Working with the Android SDK's Java packages
- Storing data
- Reading text files
- Parsing JSON and XML data
- Managing device sensors
- Playing audio