Experiment 4 use of color, string resources

Source: Internet
Author: User
Tags string methods

Lab Report

Course Name

Mobile Internet development based on Android platform

Date of experiment

March 25, 2015

Name of the experimental project

Use of color, string resources

Location of the experiment

S3009

Type of experiment

-Verification Type √ design type-comprehensive type

Hours

2

The purpose and requirements of the experiment (the knowledge points which are involved in this experiment and are required to be mastered)

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

second, the experimental environment (the hardware equipment and related software used in this experiment)

(1) PC Machine

(2) Operating system: Windows XP

(3) Software: Eclipse, jdk1.6,android Sdk,adt

Third, the contents and steps of the experiment

  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.

Four, the experimental results (the experimental source program list and operating results or experimental conclusions, experimental design drawings)

Code:

Color Reference Code

<relativelayout xmlns:android="Http://schemas.android.com/apk/res/android"

xmlns:tools="Http://schemas.android.com/tools"

Android:layout_width="Match_parent"

android:layout_height="Match_parent"

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="@color/bgroud" >

<textview

Android:layout_width="Wrap_content"

android:layout_height="Wrap_content"

android:text="@string/hello_world"

android:textcolor="@color/red_bg"

android:textsize="30SP"

/>

</RelativeLayout>

String Reference Code

<relativelayout xmlns:android="Http://schemas.android.com/apk/res/android"

xmlns:tools="Http://schemas.android.com/tools"

Android:layout_width="Match_parent"

android:layout_height="Match_parent"

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/ic_launcher"

>

<linearlayout

android:id="@+id/linearlaout1"

Android:layout_width="350DP"

android:layout_height="Wrap_content"

android:orientation="vertical">

<textview

Android:layout_width="Wrap_content"

android:layout_height="Wrap_content"

android:text="@string/hello_world"

android:id="@+id/texview1"

android:layout_gravity="center"

android:textsize="20SP"

/>

</LinearLayout>

<button

android:id="@+id/button1"

Android:layout_width="Wrap_content"

android:layout_height="Wrap_content"

android:layout_below="@+id/linearlaout1"

Android:layout_centerhorizontal="true"

android:text="@string/btn" />

</RelativeLayout>

Run Result: ()

Five, Experimental summary (analysis of the results of the experiment, experience and improvement of experimental ideas)

1, through this experiment, learned the basic color, the use of string methods

2. When setting the size of each control layout, the general control size is DP, and the font size is SP

3. When referencing resource files in layout, be careful to use @ or @+ to find the corresponding relationship

Experiment 4 use of color, string resources

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.