Don't Be a Square
Under the heading of giving credit where credit is due (but isn't it usually a debt that is due, not credit?), I got this tip from a
cat here and over here, too (actually, he's probably not literally a (feline) cat, but
who knows for sure?!?).
This is how my Layout looked prior to incorporating his expertise:
...and here's what it looks like now:
Wrangle That Rectangle
Here's what you need to do in order to wrap widgets in a box, or frame:
- In Droidio, right-click your project's
"res" folder and, if you have no "drawable" directory, select New > Directory and create it.
- Right-click the "drawable" directory and select New > Drawable Resource File
- Give it a name, such as "Rumpelstiltskin", "Tiglath-Pileser", or "Tigger: T-i-doubleGuh-Er" OR, if you are an old fuddy-duddy like me, just
give it a boring old descriptive name such as "box" or "orangeframe" or whatever seems sensible.
- Paste XML like the following over the default XML provided:
This will create a black box that can be used.
Alternatively, you could create an orange frame without padding that will thus wrap tightly around whatever widgets you want it to
decorate, such as this:
An Activity that uses the orange frame around EditTexts looks like so:
- Finally, add the following code to your Layout file:
Note: Depending on the particular effect you need, you may have to change the orientation from horizontal to vertical.
- Between the right angle bracket and the closing
LinearLayout element, cut-and-paste the widgets you want to be enclosed. In context,
here is an example that uses the black box:
As you can tell, this encloses a
TextView widget and two
CheckBox widgets in the black box; the visual effect of this is seen in the first
screen shot above.
Waterloo and More Mild Monkeys
By changing the padding values (or removing them entirely, as is the case with orangeframe) and the color value, you can have all kinds of
fun (possibly even more than a barrel of monkeys), win friends, influence people, and all your wildest and mildest dreams will come true to
boot (Vote for Pedro!).
This just scratches the surface of the havoc you can wreak ... I mean, the wonderful things you can accomplish ... with drawables in Droidio.
I am the entire team at "Found in the Translation," which produces multilingual books (paperback and Kindle versions) such as "Don Quixote: In Spanish and English, Paragraph-by-Paragraph" among many others (English paired with not only Spanish, but also French and even Finnish). You can see all those books here: http://jsfiddle.net/clayshannon/pRgQL/75/
Personal web sites that I have created can be seen at http://usamaporama.azurewebsites.net and http://bigsurgarrapata.azurewebsites.net/ and http://www.awardwinnersonly.com
Peripatetic and picaresque, I have lived in eight states; specifically, besides my native California (where I was born and where I now again reside) in chronological order: New York, Montana, Alaska, Oklahoma, Wisconsin, Idaho, and Missouri.
I am also a writer of both fiction (for which I use a nom de plume, "Blackbird Crow Raven", as a nod to my Native American heritage - I am "½ Cowboy, ½ Indian") and nonfiction: http://www.lulu.com/spotlight/blackbirdcraven