To follow along in Photoshop, open a new file, and pick your desired dimensions. Press OK to begin.

First off, if you want to change the color of your font, click on the front-most of the two colored squares in the left sidebar. The color of this square is the color of your font.

The “Color Picker (Foreground Color)” tab will appear. In this tab, you can manipulate values to get your desired color. For instance, for a black font, set the values R, G, and B to 50. R, G, and B stand for Red, Green, and Blue.

To practice manipulating font, type in, for instance, “Mammoth Interactive”. The pink lines that appear on your screen help you center your text. If you click on the “T” in the left sidebar, the header at the top of your screen will give you more options for manipulating text.

Photoshop has many fonts on your computer, and you can add more. In the header, you can choose between different kinds of fonts, including:

Seriffonts have little appendages on them. These are best used in print materials like books. The serifs remind your brain of lines, making text easier to read.

Sans serif fonts, on the other hand, don’t have the appendages. “Sans” means “without” in French, so it is literally “without serif”.

Monospace fonts, such as Courier, look old and retro because at one point, all fonts were monospace. Every letter in these fonts has the exact same width.

You can also change various properties of your text, such as its size, alignment, or whether or not you want it bold. If you go to Edit > Transform > Scale, you can change the size of your text by dragging its corner. To scale proportionally, push the Shift/Alt key. To scale from the center, push Option.

By clicking on the colored rectangle in the header, you can change font color. If you place in an image, you can match the color of your text with a color in the image. The tab “Color Picker (Text Color)” will appear. Then, if you move your cursor over the image, the cursor will transform into an eyedropper. If you click on the color in your image, your colored rectangle will change to that color. After pressing OK, you will be able to type in that color!

Welcome! Ready to get a leg up on the competition? This article will teach you how to change the size of the text in your application FASTER than ever. If you are a beginner and are looking for an introduction to coding, check out our FREE 30-minute course here: training.mammothinteractive.com/p/learn-to-code-in-30-minutes

To follow along with this example in Android Studio, go into Project view. Then go to app > res > layout, and open “activity_main.xml”. Also, in the “values” folder in “res”, select “dimens.xml (2)”.

We’ll begin with “activity_main.xml” in Design mode, which lets us drag and drop items into our application. Select two of “Plain TextView” from the Widgets folder on the left-hand side. Position the two widgets just under the “Hello World!” text already on the screen. Your display should have three lines of text:

Hello World!
New Text
New Text

In this example, we will be changing the font size of these three lines of text. In Text mode, let’s first look at assigning size the long way. Add the following beneath android:id="@+id/textView2":

android:textSize="50sp"

Make sure this line is within the topmost TextView tag. Next, copy and paste this line into the other two TextView tags.

Now, let’s say we’re not happy with our text size of 50sp. What if we want to change it to 20sp? As you can imagine, changing 50sp to 20sp manually isn’t the favored technique. If you have a large number of TextViews, it is too tedious to change them one by one.

Thus, it’s much more efficient to reference a dimension variable. These variables are declared in the “dimens.xml” file.

In that file, in the resources tag, create a dimension variable using the keyword dimen, and name it "textSize". Also, give this variable the value 50sp. Finally, close the tag. Your line of code should look like this:

The next step is to go back to the activity_main file and reference our dimension resource. To do this, write @dimen/textSize instead of 50sp in all three TextViews.

Now if we want to change the text size to 20, we don’t have to go to each TextView in our application and correct the value manually. We can just go the resources tag in our dimension file and change 50 to 20.

In this example, we’ll be looking at an online store that is converting the prices it displays for its items from CAD to USD. To follow along in Android Studio, go into Project view. Then go to app >> java >> (topmost) com.example.zebra.demo >> MainActivity.

In order to implement decimal numbers in Android Studio, we use the keyword Double. Let’s name two double variables priceCAD and priceUSD. Add the following code beneath setContentView(R.layout.activity_main);:

Double price CAD, priceUSD;

To convert prices, we need to have a conversion rate. On a new line above the one in which we declared double variables, declare a constant by using the keyword for constants: final. As well, specify the data type Double. Name this constant CAD_TO_USD, and set it equal to 0.76, a sample conversion rate.

final Double CAD_TO_USD = 0.76;

Back with our double variables, set priceCAD to equal 9.55. You can do negative numbers, but this example requires positive numbers. Note that if you want a price of 9 you have to type “9.0”. If you just put “9”, you’ll get an error. The emulator will find an integer when it wants a double variable, which requires decimal places. Also, make priceUSD equal to priceCAD + CAD_TO_USD.<

Double priceCAD = 9.55, priceUSD = priceCAD * CAD_TO_USD;

Furthermore, let’s create the code for a message to be displayed on the screen. Below the line with our double variables, type in “Toast”, select “Create a new Toast”, and hit Enter. Android Studio will auto-complete the following code with the Toast function’s parameters:

Toast.makeText(MainActivity.this, "", Toast.LENGTH_SHORT).show();

The string we want to be displayed on the screen goes into the quotation marks of the Toast function. Let’s code it as "The price in USD is " + priceUSD.

To test our code, run the emulator. You should see the text “The price in USD is 7.258000000000001”. Woah! This price contains 15 decimals. The online store probably doesn’t want to show the price of its items with those many.

To format the price to two decimal places, add the following before the string in our Toast function: String.format(). Enclose the string in the parentheses of that code.

As well, inside those parentheses, add the parameter Locale.getDefault(), in the beginning. Then replace + with a comma. Put a placeholder for the first decimal that appears after the comma. After "The price in USD is", write %.2f. %f stands for floating point number. The .2 specifies that we want only two decimal places to be shown.

If you want to specify the decimal places for more numbers, add more %fs separated by and. Separate the numbers with commas, such as priceUSD, 2.45. The value of priceUSD will be placed in f. If we have another one called 2.45, it will place that number in the second f.

For now, we’ll just use one placeholder. If you run the emulator again, you will see the price displayed with two decimal places: “The price is 7.26”.

Ready to get an edge on the competition? This article is about converting strings to decimals with numeric values stored in strings. As such, you’ll be able to simplify your code and reduce your chance of error.

To follow along with this example in Android Studio, go into Project view. Then go to app > java > (topmost) com.example.zebra.demo > MainActivity.

To begin, declare a string variable phoneName, and give it the value "Nexus5X". Do so by typing in the following code beneath setContentView(R.layout.activity_main);:

String phoneName = "Nexus 5X";

Before the semi-colon, initialize another string phoneDisplay, and give it the value "5.2". As per convention, separate the two strings with a comma.

Note that 5.2 is a string variable, and you can’t do operations on strings. Therefore, if you want to convert 5.2, which is in inches, into centimeters, you can’t multiply it by a conversion rate.

Instead, you can convert that value into a new variable. On the next line, type Double, the key word used to declare a decimal variable. Declare the double variable phoneDisplayIn, and make it equal to Double.parseDouble().

With this code, the emulator will read whatever parameter we pass as a string inside the parentheses as a double. Pass the string phoneDisplay in the parentheses.

Note that the numeric value of the phone display will be in inches. For those of you using the metric system, we’ll also need the phone display in centimeters. On the same line, after a comma, create a new variable phoneDisplayCm. End the line with a semi-colon. Your line of code should look like this:

The value of phoneDisplayCm will be equal to the value of phoneDisplayIn multiplied by the conversion rate from inches to centimeters. Let’s create a constant for this conversion rate. On a new line above the double variables, use the key word final, and create the double constant IN_TO_CM. Assign it the value 2.54, the number of centimeters in an inch.

final Double IN_TO_CM = 2.54;

Now that you have your conversion rate constant, set phoneDisplayCm equal to phoneDisplayIn times the value of IN_TO_CM.

There we go! We have variables for the display in centimeters and in inches. By converting the type from a string to a double variable, we eliminate our chance of error.

Next we want to create the code for a message to be displayed on the screen. On a new line below your double variables, type in “Toast”, select “Create a new Toast”, and hit Enter. Android Studio will auto-complete the following code:

Toast.makeText(MainActivity.this, "", Toast.LENGTH_SHORT).show();

For the displayed message, we could concatenate all of our values and strings into the quotation marks of the Toast function. However, it is much neater to create a new string containing the message we want to be shown. Then, we can just reference the string’s name in the Toast function. By doing so, we refrain from overfilling the Toast function with too many parameters.

Replace the quotation marks in the Toast function with message. In a new line above the Toast function, create the new string message. Give it the value phoneName + " has a screen display of " + phoneDisplayCm + " cm." Your line should look like so:

Run the emulator to see the values that show up on the screen. By zooming in to the display, you will see the message “Nexus 5X has a screen display of 13.208 cm.” Perfect! This is exactly what we were expecting. Now you know how about type conversion from string to decimal and how to make these operations with numeric values that are stored in strings.

Ready to get ahead of the game? Today you’ll be learning something that will give you an edge in computer science. Although constants aren’t often used by programmers, they increase the readability of programs. In this tutorial, we will use a simple math example to see constants’ usefulness in action. If you are a beginner and want to start with the basics of coding for FREE, check out our 30-minute introductory course here: training.mammothinteractive.com/p/learn-to-code-in-30-minutes

To follow along with this example in Android Studio, go into Project view. Then go to app > java > (topmost) com.example.zebra.demo > MainActivity. Feel free to hide Project view.

To understand the purpose of constants in programming, let’s look at a simple math problem: if the radius of a circle is 2.54 inches, find the circumference of the circle in centimeters.

To start off, initialize a double variable using the keyword Double. Double variables allow our numbers to have decimal places. Call it radiusInInches, and assign it the value 2.54. Do so by typing the following code beneath setContentView(R.layout.activity_main);:

Double radiusInInches = 2.54;

The next variable to declare is one for the circumference (perimeter) of the circle. Let’s call it perimeterInCentimeters. Assign it the value of the mathematical formula for the circumference of a circle: 2 * pi * r = 2 * 3.14 * 2.54. Note that we also have to multiply the value by 2.54 because that’s approximately the number of centimeters in one inch.

Double perimeterInCentimeters = 2 * 3.14 * 2.54 * 2.54;

Although our problem is technically solved, our code isn’t quite easy to understand. Later on, when you read this code again, you may wonder what the numbers being multiplied mean. Since our radius is 2.54 and that number appears twice in our formula, you might be tempted to say that we are actually using the formula for the AREA of a circle (pi * r^2).

This is where constants come in. They make code easier to understand. The key word final is used to declare a constant. Note that we can declare constants from any data type desired. In this case, we’ll declare a double constant because our number contains decimal places. On a line between your two declared variables, declare a double constant named CENTIMETERS_IN_ONE_INCH. Set it equal to 2.54.

final Double CENTIMETERS_IN_ONE_INCH = 2.54;

Notice the difference in the naming conventions for constants and variables. As you can see, the names of variables begin with a lowercase letter, and all the other words in the name begin with an uppercase letter. For the names of constants, all letters are in uppercase, and the words are separated with underscores.

Now let’s replace the numbers in perimeterInCentimeters with more meaningful names. Change the first 2.54 in perimeterInCentimeters to radiusInInches. Replace the remaining 2.54 in that line with CENTIMETERS_IN_ONE_INCH.

Hooray! The code looks much easier to understand. However, there’s one more problem we have to tackle: the “3.14”. There’s a predefined constant in Android Studio called Math.PI. It is accurate to 15 decimal places of Pi, which minimizes round-off errors. You can replace 3.14 with this constant for better precision.

That’s that! Now the programs you create will be much more easily read. This is helpful because code is much more often read than written. If you want to improve your coding skills even further, check out our FREE 30-minute beginners course here: training.mammothinteractive.com/p/learn-to-code-in-30-minutes