Android Beginner First Summary

Source: Internet
Author: User

Catalog of Eclipse-created projects:

SRC Source Code

Gen R file Registration resource ID (without IO)

Assets is used to store resources that do not need to be compiled (folders can exist)

Bin apk

Libs is used to store external libraries

The RES resource is registered in the R file (named: letter: Lowercase _ number; number cannot begin)

Drawable Pictures

Layout layouts xml: < Name property = value > </name > < name attribute = value />

Layout of menu Menus

Valuse length string style

Raw stores resources that you do not want to compile (cannot create new folders, register in R file)

androidmanifest.xml manifest file

Problem solving:

1. FC

An error occurred, whether to force shutdown

2. Log LogCat

Verbose All information log.v (String str,string str); Black

Debug debug information//Blue

Info

Warn

Erro Red

Assert assertion

3. Solve FC

1, look at the log

2, the cause of seeing the wrong

650) this.width=650; "Src=" http://note.youdao.com/yws/public/resource/95b3d57b16fcd617448e2ae0042f726d/ 536480f3c838427fb03d144d6a877a9f/00b0476c02544baf878da1ba7a20a467 "style=" Border:none;line-height:1.5;height: auto; "alt=" 00b0476c02544baf878da1ba7a20a467 "/>

3. Find the wrong code

From the top down to find the first appearance of the code you write the location

In general, the first sentence under caused by 650) this.width=650; "Src=" http://note.youdao.com/yws/public/resource/ 95b3d57b16fcd617448e2ae0042f726d/536480f3c838427fb03d144d6a877a9f/0cf29b84ec504e6bafc28c6e3b10abbe "Style=" Border:none;line-height:1.5;height:auto; "alt=" 0cf29b84ec504e6bafc28c6e3b10abbe "/>

4. Double-click to locate the past

4. Project Error

Re-compiling

5, R error

1, resource problem (resource naming problem A~z _ Digital number cannot start)

2, r file Import error (can import Android. R

3, compile (forget to automatically compile)

A, Project---> Build Auto ... To hook up

B, recompile

Project---> Clean

6. Drag control appears classcastexception

Project---> clean



Use of Genymotion: (Speed Simulator)

Genymotion + VirtualBox

Steps to use:

1. Installation

2. After the installation is complete, open genymotion, close after opening

3. Copy the image file to

C:\Users\admintor\AppData\Local\Genymobile

Cover out

4.

ImageView Storing pictures

<imageview

Android:id= "@+id/imageview1"

Android:layout_width= "Wrap_content"

android:layout_height= "Wrap_content"

android:src= "@drawable/ic_launcher"

Foreground picture

Android:scaletype= "Center"

Center Center

Fitxy Stretch Fit Control size

FitStar the origin from the upper left corner (the picture scale does not change)

/>

Code

Set foreground picture

Imageview.setimageresource (R.drawable.ic_launcher);

Set background

Imageview.setbackgroundresource (R.drawable.ic_launcher);

Set Stretch mode

Imageview.setscaletype (SCALETYPE.FIT_XY);

ImageButton

Subclass of ImageView

Layout Manager:

1. LinearLayout Linear layout

<linearlayout
android:orientation= "Horizontal"

Direction value: Horizontal horizontal direction

Vertical vertical Direction

>

Special properties:

This property only takes effect if the control is placed in the LinearLayout

Android:layout_weight= "2"

Weight split remaining space

android:layout_gravity= "Center"

Value: Center up or down (center horizontally, vertically)

Common Properties:

Control has properties in any layout

Set the gap between the control and the content

android:padding= "20DP"//Up or down

Android:paddingleft= "10DP" left

android:paddingright= "20DP" right

Android:paddingtop= "30DP" on

Android:paddingbottom= "40DP"

The gap between controls

Android:layout_margin= "20DP" //up or down

android:layout_marginleft= "10DP"

android:layout_marginright= "20DP"

android:layout_margintop= "30DP"

Android:layout_marginbottom= "40DP"


How the content is aligned in the control

Android:gravity= "Top|right"


Relativelayout Relative layout


How controls are aligned in the layout

Android:layout_alignparentleft= "true" to align Left

Android:layout_alignparenttop= "true" on alignment

Android:layout_alignparentright= "true" right

Android:layout_alignparentbottom= "true" under

Android:layout_centerhorizontal= "true" Horizontal Center

Android:layout_centervertical= "true" vertically centered

Android:layout_centerinparent= "true" center


Alignment between controls

Android:layout_aligntop= "@+id/textview2" on

Android:layout_alignleft= "@+id/textview2" left

android:layout_alignright= "@+id/textview2" right align

Android:layout_alignbottom= "@+id/textview2" to align


The position relationship between controls:

Android:layout_above= "@+id/tf" above XX

Android:layout_toleftof= "@+id/tf" on the Left

Android:layout_torightof= "@+id/tf" to the right

android:layout_below= "@+id/tf" under XX


Framelayout Frame Layout

Features: Cascading controls

Android:layout_gravity= "Right|top"


Tablelayout Table Layout

Every line is TableRow.

Height is determined by the highest-height control in each row

The width is determined by the control of the widest width in each column.


Absolutelayout Absolute Layout (not recommended)




GridLayout Grid Layout (added after 4.0)

Android:layout_column= "2"

android:layout_row= "3"//declare control in the same row


Android:layout_columnspan= "2"

Android:layout_rowspan= "2"//Declare the rows occupied by the control



Layouts can be nested.




Android Beginner First Summary

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.