Java Day 3: Labeling Buttons with Strings

Vocab

px
Pixels – corresponds to actual pixels on the screen.

in
Inches – based on the physical size of the screen.

mm
Millimeters – based on the physical size of the screen.

pt
Points – 1/72 of an inch based on the physical size of the screen.

dp
Density-independent Pixels – an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both “dip” and “dp”, though “dp” is more consistent with “sp”.

sp
Scale-independent Pixels – this is like the dp unit, but it is also scaled by the user’s font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user’s preference.

NOTE: comments can’t be insterted between tags

Strings

Every text displayed should be wrapped into a string for packaging sake. The program gets a little piffy (note the caution icon–yellow triangle– on “large text”) when you try to “hardcode” text. So, day one of coding my new app, Calcu, is making strings so the buttons have something legit to display. A big learning moment was installing the Obelus (the division symbol– yeah I didn’t know the name of it either!). Using a character map to find the unicode, I was able to reference this particular character with “&#247.” Very exciting.

obeluscode

xml code

obelussymbol

View using Eclipse’ WYSIWYG

calcu

I made this using RelativeLayout

Text Alignment

I aligned the zero in the text box with gravity. Android:gravity=”top|right” different from html. I like it. I imagine a magic gravity wand drawing all text into that part of the box. It’s not a matter of alignment. It’s forces of nature at work!

Links for symbols:
Unicode and HTML – Wikipedia, the free encyclopedia

List of XML and HTML character entity references – Wikipedia, the free encyclopedia.

Advertisements

About KC

I am Katarina Countiss, a multimedia designer. I like blogs, games, art and technology. I am curious about how things are made.
This entry was posted in App. Bookmark the permalink.

One Response to Java Day 3: Labeling Buttons with Strings

  1. Pingback: Java Day Four: Method Time | Katablog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s