Layouts, Labels, Textboxes, & Creating Color

While creating attractive user interfaces is easy with App Inventor, it may not be obvious. In this module you will learn how to make use of Layouts, Labels and Textboxes while creating all sorts of new colors. Yes, it is possible!

Labels are similar to Buttons in that they are found in the User Interface Palette in the Designer, but are different in that they are not clickable. Anytime you want to include text in the UI of your app, you can use a label. Labels can display things like: instructions, a title or a list. For example in a game app, a user will want to see things like the score, the level, the time remaining, etc. All of these can be easily displayed using a label.

Textboxes are also found in the User Interface Palette. They are used when a developer wants an app user to input information, like a name or date. Layouts help to format components so they are attractive and organized on the screen. The example in this module will use the HorizontalArrangement.

Creating attractive User Interfaces in App Inventor tends to frustrate people mostly because of what I like to call, the Color Controversy. New developers see the limited saturated hue options in the Designer and go nuts. How is it possible to create nice looking layouts if there are only 8 saturated colors, a few greys, black and white??? Its not. We completely agree. But those are hardly the only color options. One just must know where to look…

To practice using Layouts, Labels and Textboxes and to dispel the limited color option myth (and end the fuss once and for all), we will create a simple form.

Designing a Form

When the Label is active (highlighted in green in the Viewer), its properties display in the Properties panel on the right of the Designer screen. Changing the properties of any component reformats it to your liking.

Changes you make in the text box will be reflected in the Viewer and on your connected mobile device.

img0

     Note: changing the display text is different than changing the label name.

Re-Naming Labels

Whenever you create a new label in the Designer, it will automatically be named Label1, Label2, Label3, etc. Because it will be difficult to remember which label displays which information when you begin coding, it is good practice to rename labels to clearly describe their function.

The recommended standard is to use a capitalized descriptive name, followed by the capitalized component name - with no spaces between words. Examples include: “ScoreLable”, “TitleLabel” or “InstructionslLabel”. (AppInventor doesn’t allow spaces so if you accidentally type the name “Score Label” with a space in between the words, App Inventor will automatically insert an underscore and name your label “Score_Label”.) If you prefer, you can also purposely enter an underscore in a name: TitleName_Label.

Textbox Hints

Notice on your mobile device that the Textboxes have light grey text inside them. One of the properties of Textboxes is “Hint.” The Hint Property gives you the flexibility to provide instructions inside the Textbox instead of on a Label. For example, we could have eliminated the Labels altogether and instead, typed the Hints: “Enter Last Name”, “Enter First Name”, “Enter Phone Number” and “Enter State Abbreviation Where You Are Registered to Vote” as shown in the following image (#10).

img0

In this tutorial we decided to use Labels to display text instead of Hints, so we merely deleted the text in the Hint Property for all of the Textboxes.

Also note in image #10 that the line of text in the last Hint is cut off. This can be easily fixed by adjusting the width of the Textbox in the Properties Panel. We will do this in the next section.

Using Layouts

So far our form is very basic and uninteresting. We can use the Layout Component to make it more streamlined.

Now the HorizontalArrangement will fill the width of the screen.

Take a look at the Components Panel. Notice how LastName_Label and LastName_Textbox are indented or nested inside of HorizontalArrangement1. This is another way to double check that indeed those components are inside of the HorizontalArrangement layout.

Next we will make some minor adjustments to the Textboxes to ensure ensure that no text will get cut off inside of the LastName_Textbox.

(You may find it difficult to position the State_Label and State_Textbox because the text on the Label is so long. Try positioning the State_Textbox into the HorizontalArrangement first and then adding the State_Label to the left of the Textbox.) Your Designer screen should look similar to image #13. Notice how the Labels and Textboxes are nested in the Components Panel. (Also note that 3 of the textboxes are white, this is simply to show the layout of the textbox, you will have chosen “None” for the Textbox Background Color, so your image will not show the outline of the Textboxes.)

img0

Your mobile device will resemble the following image (#14).

img0

To make the Layouts more obvious on screen, we will add a background color to each. Don’t worry about the limited color options in the Designer, we dispel the Color Controversy later in the Blocks Editor.

Labels as Spacers

To make our form more visually appealing, we will create some space between the lines of text by using Labels as spacers.

img0

The time has come to play with color! You will soon discover that whatever color choices you make in the Designer can be easily overridden by the infinite possibilities the Blocks Editor (and Internet) has to offer. Say goodbye to boring UI!

Playing with Color

Head over to the Blocks Editor.

The first color change we will make is to the Screen1 Background Color.

Since we are using the when Screen1.initialize do block, changes will only reflect on your mobile device once you reconnect with AI Companion app or when you make a change in the Designer. Instead of reconnecting your mobile device each time you make a change in the Blocks Editor, simply toggle your screen to the Designer and make a small change, like clicking the checkbox next to FontBold or FontItalic in the Properties panel for a Labels. This tactic updates the app so you can view the updated Screen1 Background Color on your mobile device.

Doing so will enable you to try many different color schemes. Some examples are shown in images #22, #23 and #24.

img0
img0
img0
img0

Explore further by adding new colors and set blocks to change the TextColor of the Labels as shown in image #25.

Creating Colors

You can utilize the color hues that App Inventor offers to make combinations, or wait for it, wait for it… you can make your own color! This means that any color you can possibly want, you can use in App Inventor. And you can use the Internet help you find colors that work well together to design exceptionally beautiful user interfaces.

Hovering over a color in the App Inventor palette reveals its RGB values as shown in image #26. The RGB (R=Red, G=Green, B=Blue) system uses values 0 – 255 to represent the intensity of each color. This allows for an enormous amount of colors to pick from, 256 x 256 x 256 = over 16 million possibilities! But how do you do this if App Inventor only offers a 7 x 10 grid? We will tell you in a sec. But first, let’s go to the web.

img0

Knowing a color’s RGB values can assist you in finding out the hex number (a 6 digit number used in HTML and CSS to represent Red, Green and Blue), the Pantone equivalents and complimentary colors to easily expand your UI. Simply plug your RGB values into a free website such as RGBto and discover an array options as shown in images #27 and #28. (In this example we use the RGB color 153, 153, 255 from the App Inventor grid.)

img0

With sites like rgb.to, you can discover an assortment of complimentary hues to go with any color you pick. The colors display Hex numbers (indicated with the hashtag) and clicking on any of the suggested colors (say #99e6ff for the blue hue) will reveal this color’s RGB values as shown in image #29.

img0

Then… ta da… you can add this value into App Inventor with the make color block found at the bottom of the Color blocks as shown in image #30.

img0

Yes indeed, this means that you can create your own color and color combos in App Inventor, the possibilities of are pretty much endless (#31-#36).

img0
img0
img0
img0
img0
img0

Another awesome free web resource is the Adobe Color wheel (also known as Adobe Kueler): https://color.adobe.com/create/color-wheel/. Here you don’t need to know the RGB values ahead of time, you can just pick colors whimsically from the wheel (image #37) to discover color combinations or you can select from a pre-defined color scheme palettes (image #38). Both options give you the associated RGB values and Hex number.

img0
img0

(The endless color schemes appear on the Explore page. Hover over a color scheme to reveal a pop-up menu, click “edit copy” to be taken to the color wheel for that combination of colors as shown in image #39.)

img0

As you can see designing the UI for a simple form in App Inventor is a creative process with an array of unexpected possibilities. In future modules we will explore the use of other layout components: VerticalArrangement and TableArrangement.