Purpose
- Learn how to use color and string resources in Android.
- Understand how size and layout resources are used in Android.
Requirements
- Use color resources for activity and view in project;
- Use string resources and understand the reference mechanism of string resources;
- Set the dimensions for the view components in Android;
- Use layout resources to place components on the interface at the specified location.
Principle
Android resource management mechanism.
Process
1. Setting up virtual machines
2. Establish a project named Sokodu
3. Modify the string resource file (String.xml) to increase the required string resource
4. Add the Color.xml file under the values file and increase the required color resources
5. Using color resources and string resources
"Main Code"
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"Xmlns:tools="Http://schemas.android.com/tools"Android:id="@+id/linearlayout1"Android:layout_width="match_parent"Android:layout_height="match_parent"android:orientation="Vertical"android:padding="30dip"Android:paddingbottom="@dimen/activity_vertical_margin"Android:paddingleft="@dimen/activity_horizontal_margin"Android:paddingright="@dimen/activity_horizontal_margin"Android:paddingtop="@dimen/activity_vertical_margin"Tools:context=". Mainactivity"Android:background="@drawable/flower"> <TextView Android:id="@+id/usernametv"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="TextView"Android:textcolor="#000000"/> <TextView Android:id="@+id/maintitle"Android:layout_width="wrap_content"Android:layout_height="wrap_content"android:layout_gravity="Center"Android:layout_marginbottom="25dip"Android:text="@string/main_title"Android:textcolor="#000000"android:textsize="24.5SP"Android:textstyle="Bold"/> <Button Android:id="@+id/continue_btn"Android:layout_width="fill_parent"Android:layout_height="wrap_content"Android:text="@string/continue_label"Android:background="#5FFFC0CB"/> <Button Android:id="@+id/new_btn"Android:layout_width="fill_parent"Android:layout_height="wrap_content"Android:background="#5FFFC0CB"Android:text="@string/new_game_label"Android:layout_margintop="20DP"/>
"Run Results"
"Experimental Experience"
Through this experiment, basically mastered the use of string resources and color resources, because each experiment is very consistent, so in the process of learning is also more interested. In the experiment again and again, constantly let their project is the interface design more and more beautiful, but also let more and more functions.
The use of four color and string resources in experiment