It is essential to have a dimensions XML file in every android project you create. To be used the same dimensions multiple times and hardcode it is not good programming practise. It is easy to forget about one when you are a beginner.
I am going to step you through how to create one and link it up to your android page. To do so I am going to use the main page which we have already created in the previous guides.
1. Go to values
2. Right click on values > new > Values resource file
3. A new dialog box should then show up enabling you to enter a name for the resource. It should always be called dimens.
4. You will then be taken to you new XML page once you click OK. In there you can begin to declare the dimens which you want to have.
You do not need to set up all of your dimensions at once these can be added to as you go along.
To declare a new dimens:
The same format above should be used for all dimens being used.
5. Once you have declared the dimens, you can now link it up to the app page.
To do so go to layout folder > main.xml
6. I am going to change the TextViews size of text. You use the same aspect each time.
This can be done two ways:
Locate the properties palette on the left hand side of the screen. Look for a resource which says Text Size. Click on it.
Within the text size box select the three dots. This will then show another dialog box which will enable you to choose the size that we have just added.
Once you have click OK. You will then see that IntelliJ has added:
The second way to do it is:
Click on Text at the bottom of the screen. You will then be shown the XML code for page.
You may find this hard to understand at the start if you have not done XML before.
At the top of the page you will see the TextView. This is where we want to add the background.
Take a new line under the last sentence you have and write:
It should now look this this: