Homework2-meierdg
This app is for a casual laugh, or for the more superstitious, a means for advice. It is a fortune cookie app that starts with 4 preloaded fortunes (I know, I know, I went all out!) that also lets you add in your own fortunes.
You can single click the listed fortune to delete it. By clicking “Get your fortune!” it brings you to the fortune cookie screen which randomly selects a fortune and displays it on the screen. A single click provides another random fortune, while a long click brings you back to the main screen.
The most obnoxious part about this was probably getting the text to show up on the picture. The picture is actually set as the background, which can just be done in the xml with a
android:background=”@drawable/imagename”
The text was a bit more annoying. I originally had a picture with the paper at an angle, which required me to implement a TextView and change the drawable, but it became far too tedious to match the angles, so I gave up and went for a horizontal piece of paper. To get the text on it, I used a deprecated layout, AbsoluteLayout, and just fiddled with it until it fit on the paper.
To do this, in the xml you wrap the TextView in an <AbsoluteLayout>, which looks normal:
<AbsoluteLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”horizontal”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
>
And to position the TextView you add in properties to the TextView itself as shown:
android:layout_x=”85dp”
android:layout_y=”133dp”
changing the actual values to whatever you need them to be.
Other than that, the coding is pretty straightforward. However because I’m using an AbsoluteLayout (also probably one of the reasons why its deprecated), the text will probably not be lined up with the paper if the device/emulator used is a different size.