Posts Tagged ‘Screen’

Android: rendering a path with a Bitmap fill

Click here to read Android: rendering a path with a Bitmap fill

This Android tutorial shows how to render a Path that is filled by a Bitmap and displays stroke in a different color. It also explains how to manipulate the texture coordinates to make it independent of the position of the path, just like a mask, but without using any of the PorterDuff rendering modes. The code featured in this code was created and tested on Android 2.1, both on a real and at an emulated device.

Here’s a video of the example application in action:

If you can’t play the video, don’t worry: there is a screenshot of the application at the bottom of this post.


Unity: Creating GUI transitions

Click here to read Unity: Creating GUI transitions

This Unity scripting tutorial shows how to manipulate the GUI system origin to create an animated transition, so you can make your GUI’s look more interesting. To keep things simple, this post shows how to create an horizontal transition between two Text Areas using a couple of buttons. All code featured below is available for download at the end of the post.

To achieve an animated transition, the origin of the GUI system must be manipulated. This is done by changing the elements of the matrix that sets the rendering reference point of the GUI elements. Conveniently, Unity allows us to do that by manipulating the GUI.matrix values. So, the script requires a Matrix4x4 object. Also, to make the code more readable, a Vector3 is going to be created, also making it easier to translate the GUI system origin. Here’s the script:

Android: Obtaining the current orientation using a BroadcastReceiver

Click here to read Android: Obtaining the current orientation using a BroadcastReceiver

This Android tutorial explains how to create a Broadcast Receiver that detects screen orientation changes that are triggered by rotating the device. Since screen orientation changes don’t happen every second, it’s better to detect it using a BroadcastReceiver instead of a Service. Both can be used to execute tasks on the background, but the BroadcastReceiver execution will be triggered only when the desired Intent is filtered (in this case, a screen orientation change). Right after the execution, the background task is killed, which is ideal since a BroadcastReceiver can be created to obtain the new screen orientation only after it has changed.


Android: Creating a WebView dialog

Click here to read Android: Creating a WebView dialog

This Android post shows how to display a WebView inside a Dialog, that renders a website to the user. Since the WebView can load just about any web page, it’s possible to provide any information to users without launching the web browser, so they never have to leave the application.

For this tutorial, all code had been developed and tested in Android 2.1, both on an emulator and on a real device. As usual, an example application with the code featured in this tutorial is available for download at the end of the post.

The first thing required to place a WebView inside a dialog is to create a custom Dialog. After that, a WebView can be added to it. The easiest way to do that is to create a new Android layout file (in Eclipse, just right click the Project folder and select New -> Android XML file). Then, add the following code: (more…)

Android: how to create a loading screen – Part 3

Click here to read Android: how to create a loading screen – Part 3

This is the third and final post of a series that explains how to code a loading screen for Android. The other two previous posts (which can be found here and here), used two distinct approaches to solve the problem of executing code on a background thread and update the progress back to the application’s UI thread. However, both of them relied on an instance of the ProgressDialog class to display the current progress. In the following paragraphs, instead of using this type of dialog, a custom View inflated from a layout XML file is going to be created to achieve that purpose.

As the other two previous posts, all the code in this article has been created and tested in Android 2.1. An example Eclipse project is available at the end of the post.