Tag Archives: example

Android Rotate and Scale Bitmap Example

I built an Android demo app so I could test my understanding of displaying bitmaps on a canvas. I had done scaling of bitmaps, rotation of bitmaps, and translation from one origin to another, but I had not done more than one of those transformations at a time.
Full source code for the Android example is provided. Continue reading

Posted in Android | Tagged , , , , | 7 Comments

Tridroid – Android Switch Fragment Demo

I gave a presentation last week at my local Android developers’ meetup group, Tridroid. The topic of the meeting was fragments. In my presentation, I described a fragment I built to implement simple switches. The figures below show what the demo app looks like. Links to the full presentation and the demo source code are provided. Continue reading

Posted in Android | Tagged , , , , | 1 Comment

Drag-Drop for Android GridView (V4)

About a year and a half ago, I built an example Android app that allows you to drag images from one spot on a GridView to another. I have had several requests to show how the drag-drop framework used in that example could be adapted to the current Android support (V4+) for drag-drop operations. I have done that work and I am making the source code available in this post.

The sample app works the same as the one described in “Drag-Drop for An Android GridView”. There is a grid displayed on the screen. An “Add Image” button allows you to add images to the screen. Those images can be dragged onto the grid. Any images in the grid can be dragged around from one spot to another. There is also a trash can icon on the screen. Images can be dragged there to remove them from the screen. Continue reading

Posted in Android | Tagged , , , | 41 Comments

Android Fragments Example

I have been using Android Fragments for about a year now so I am getting more comfortable using them in my app work. Several times in that time period, I have started apps with Fragments in Android 4+ and had to rework them so I could support older versions of Android. For me, that’s Android 2.3.3 (API 10). Fortunately, that’s easy to do because of the Android V4 Compatibility package that allows you to use Fragments in the earlier versions.

Since the need keeps coming up for me to have both Fragments and backward compatibility, I decided to build myself a simple demo app that combines both. The demo app helps me remember how to do it. Often, the demo app is my starter kit for a new app. That’s what I am writing up and sharing in this blog post.
Full source code for the demo app is provided. Continue reading

Posted in Android | Tagged , , , | 12 Comments

Three Variations for Image Square Grids in Android

In a new Android app I am working on, I have a need to display a a square grid of images. I have tried several variations of doing this using a GridView. Each of the solutions involves using aViewTreeObserver, which is something I would not have thought of on my own. Fortunately, I found several notes on StackOverflow that pointed me in the right direction.

I’ll describe three of the variations in this blog post. The end result for each variation is good: square images on a grid. My favorite variation is the one in which the sizes of the images are determined dynamically, based on the size of the screen. It requires the least amount of work and delivers good results.

Complete source code is provided for all three variations.
Continue reading

Posted in Android | Tagged , , , , , , | 4 Comments

Improved Drag-Drop for an Android GridView

I have an improved version of my tutorial app described in “Drag-Drop for an Android GridView”. It allows a drag-drop sequence to be initiated from any touch event. The earlier version required the user to do a long click (press) before dragging would start.
Continue reading

Posted in Android | Tagged , , , | 113 Comments

How To Build A Simple Help Screen in Android

I released my first app to the Android Market recently. It was just complicated enough that I thought I should provide some help screens inside the app. I have taken what I did there and built a demo app, in order to illustrate how one can build a simple help screen in Android.

My simple Help screen consists of a summary page where there is an image and a brief description for each help topic. Touching the image takes you to the full help text for a topic. All of the help text comes from xml files in the resource folders. The help text can include paragraphs, text formatting (bold, italics), and even links to web pages. Even if you do not need a Help screen for your app, knowing how to have formatted Html text in an Android text view could be of use to you.
Continue reading

Posted in Android | Tagged , , , , | 9 Comments