The use of four color and string resources in experiment

Source: Internet
Author: User

Purpose

    1. Learn how to use color and string resources in Android.
    2. Understand how size and layout resources are used in Android.

Requirements

    1. Use color resources for activity and view in project;
    2. Use string resources and understand the reference mechanism of string resources;
    3. Set the dimensions for the view components in Android;
    4. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.