Presentation is loading. Please wait.

Presentation is loading. Please wait.

You have to remember that  To create an AVD(Android Virtual Device)  The Structure of Android Project  XML Layout  The advantage of XML Layout  Android.

Similar presentations


Presentation on theme: "You have to remember that  To create an AVD(Android Virtual Device)  The Structure of Android Project  XML Layout  The advantage of XML Layout  Android."— Presentation transcript:

1

2 You have to remember that  To create an AVD(Android Virtual Device)  The Structure of Android Project  XML Layout  The advantage of XML Layout  Android Emulator  To use Eclipse in Android Project Review

3 ISO 639-1 http://developer.android.com/reference/java/util/Locale.html English is represented by en French is represented by fr German is represented by de (from the endonym Deutsch) Italian is represented by it Korea is represented by ko Japanese is represented by ja (even though its endonym is Nihongo) Portuguese is represented by pt Spanish is represented by es (from the endonym español) Swedish is represented by sv (from the endonym Svenska) Locale List

4 Course Objects  Understand the views and layout, layout, utilizing management Find out about the different techniques. Contents  View, ViewGroup  TextView  ImageView  Button  EditText  Linear Layout Contents

5 The layer of Views  Android applications that make up the main unit's screen activity can not be seen directly on the screen, in the view the user -facing activity is the reality.  Sign in multiple views of a configuration of activities and these activities are the things one application.  In view of the layout to place the activity refers to the technique.  View Widget : The user interface configuration looks directly, and often referred to as a control. View Groups : View acts as a container, this class is called the layout of classes.  View the group, yet there are classes that may be used as the widget. If you want to know the details of a particular widget should study Starting with its super class.  The subclass inherits all the attributes of the super class. 1. View

6 Widget hierarchy  View a Java class is a kind of root is derived from Object.  View all classes that derive directly from the right is a widget that can draw their own capabilities. 1. View Object View TextView ImageView Button EditText CompoundButton CheckBox RadioButton AnalogClock AutoCompleteTextView ToggleButton Chronometer DigitalClock ImageButton SurfaceViewGLSurfaceView VideoView ProgressBarAbsSeekBarRatingBar SeekBar EditText

7 View Groups hierarchy  ViewGroup is derived from the subclasses of View.  With other views, including the child and the child has the ability to sort. 1. View Object View ViewGroup FrameLayout AbsoluteLayout AdapterView LinearLayout RelativeLayout AbsListView RadioGroup, ZoomControls TableLayout, TableRow ViewFlipper ViewSwitcher AbsSpinner ListView GridView WebView ScrollView, HorizontalScrollView TabHost, TimePicker, DatePicker ViewAnimator ImageSwitcher TextSwitcher TabWidget Spinner Gallery

8 The example that is related TextView Practice(1/6) TextView 1 TextView 2 TextView 3

9 Practice(2/6)

10 Practice(3/6) singleLine/res/values/string.xml Hello World, SingleLineActivity! SingleLine Hello Lovely Panama

11 Practice(4/6) singleLine/res/layout/main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" />

12 Practice(5/6) singleLine/res/layout/main.xml <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/greetings" android:textColor="#ff0000" android:textSize="20pt" android:textStyle="italic" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/message" android:textSize="20pt" android:background="#0000ff" />

13 Practice(6/6) singleLine/res/layout/main.xml <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Good Morning" android:textColor="#8000ff00" android:textSize="5mm" android:typeface="serif" />

14 Attribute of View  id Defines a view called the name, and code references a view from an XML document using the id, so intuitive, a good idea to name. Form : @[+]id/ID - @ : id of the resource (R.java) means that in the definition or reference, and shall be unconditional. - + : ID means that the new definition, and can see the poem is omitted. - id : Reserved - / : But after writing your name, ID, so the command must comply with the rules for its own name, and the view will not overlap each other. ex) android:id=“@+id/name” : id is given which is called name in text view. If you specify an XML document ID to R.java this name is defined as an integer constant. When referenced in the code view findViewById method invocation, argument passing reference to the view id. It is compulsory to all views that do not need to specify the id, the code does not require reference to the widget id is usually omitted. 1. View

15 Attribute of View  layout_width, layout_height Specify the width and height of the view, and horizontal and vertical size for each direction can be specified. As one of the following three attribute has a value. - fill_parent : It fills the parent of a given size. - wrap_content : Fills only the size of the contents. - Integer size : Adjusted to the size specified. ex) The caption which is contained “Start” 1. View Unit : px, in, mm, pt, dp (or dip), sp (or sip)

16 px Pixels - corresponds to actual pixels on the screen. in Inches - based on the physical size of the screen. mm Millimeters - based on the physical size of the screen. pt Points - 1/72 of an inch based on the physical size of the screen. dp Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp". sp Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference. Unit

17 Attribute of View  Background View, which specifies the background color and images can be specified as many as. When designating the four types of color is applied and to specify the background color as well be applied to all properties. - #RGB - #ARGB - #RRGGBB - #AARRGGBB ex) #ff0000 (#f00) : Red, #0000ff : Blue  Padding Specify the interval between the contents view. (I.E. padding ) Specifies the padding property values ​​ for the four directions can be adjusted margins. Value of attribute : paddingLeft, paddingTop, paddingRight, paddingBottom 1. View

18 Attribute of View  Visibility Specifies whether the view displays, and down to the attribute has a value of one of the three. - visible : A Status that can be seen. - invisible : Hidden state, occupies seat. - gone : Hidden state, is taking place.  clickable, longClickable Want to receive mouse click events, Long Click to specify whether the event should be. - click : With your fingers while holding the view - longClick : I wait for my status as a view of the finger holding down the The authenticity of one of them, so no true or false to specify the value.  Focusable Specifies whether keyboard focus should be. The default value is set to false, and if necessary to change the property to true. Editor, like a button or a derived class of the user input is required, has been designated to be true by default. 1. View

19 TextView  String that receives the output and input widgets  Hidden and the input function is activated in a subclass EditText.  text Output to a text view, the most important attribute string. Literal and as a resource to the assignment. 1. View FormDescription “String”Wrap the string with double quotes is just an assignment. @[Package:]type:nameSpecify by reference to the resource. string.xml, @string/id ?[Package:][type:]nameShould be attributed to the theme.  textColor Specifies the color of the string, and the default is an opaque gray. #RRGGBB or #AARRGGBB Format specifies the intensity of each color component.

20 1. View TextView  textSize Specify the font size of text, and when you specify a number followed by a mistake of type sp, dp, px, in, mm, and is specified as a unit.  textStyle Specify the properties of the font. normal, bold, italic or write to one of the '|', surrounded by more than one can specify a constant value. ex: “bold|italic”, “normal|italic”  typeFace Specifies the font's appearance, and, normal, sans, serif, monospace, select one of the possible. In a mobile environment, there are restrictions on the number of embedded fonts.  width, height The size of the text view is the width and height are specified as a value and units. Text view alone, if there is a little child in the layout as most of these properties because there are rarely used.

21 1. View(ImageView) ImageView  Desktop icon or bitmap output, resources, files and content, as well as a provider or can be displayed as an image on the web.  src Specifies the output image is the most important properties. Resources, mainly the image has a copy @drawable/ID to the output image format is used.  maxHeight, maxWidth Specifies the maximum size of output image  adjustViewbounds To keep the aspect ratio of the image will be adjusted appropriately by the image view, you specify the size, and attribute values ​​ either true or false is used.  Other cropToPadding, tint, scaleType

22 Practice(1/4) ImageView  ImageView is supporting to jpg, png, gif images  Since SDK 1.6 by the density and the presence of three folders, each folder for each image resolution put the operating system determines which image to use.

23 Practice(2/4) ImageView/layout/main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> Project name: ImageView Build Target: Android 2.3.3 Package name: exam.imageview

24 Practice(3/4) ImageView/layout/main.xml <ImageView android:layout_width="150dp" android:layout_height="150dp" android:src="@drawable/korea" /> <ImageView android:layout_width="fill_parent" android:layout_height="wrap_content" android:src="@drawable/android" android:maxHeight="70px" android:maxWidth="120px" android:adjustViewBounds="true" android:tint="#4000ff00" />

25 Practice(4/4) ImageView/layout/main.xml <ImageView android:layout_width="150dp" android:layout_height="150dp" android:src="@drawable/panama" />

26 1. View(Button, EditText) Button, Edit  View, TextView is a subclass of the one that does not have its own properties.  Button  EditText : Received from the user typing the command Toast EditText Button

27 Practice(1/4) ButtonEdit/layout/main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" />

28 Practice(2/4) ButtonEdit/layout/main.xml <EditText android:id="@+id/edit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Input here" /> <Button android:id="@+id/btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="OK" />

29 Practice(3/4) ButtonEdit/src/ButtonEditActivity.xml package exam.buttonedit; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class ButtonEditActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);

30 Practice(4/4) ButtonEdit/src/ButtonEditActivity.xml Button btn = (Button)findViewById(R.id.btn); btn.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { EditText edit = (EditText)findViewById(R.id.edit); String str = edit.getText().toString(); Toast.makeText(ButtonEditActivity.this, str, Toast.LENGTH_SHORT).show(); } }); }

31 Preview Tomorrow, We are going to study  Linear Layout  Absolute Layout  Frame Layout  Table Layout  Nested Layout  Layout Management  The Application that is sending e-mail.

32 2. Linear Layout LinearLayout  Child view horizontally and vertically, side-by-side with the layout, the most simple and intuitive, and a high frequency of use.  Orientation Property that determines the orientation of the view (Default is horizontal) vertical : Rothschild arranged vertically from top to bottom horizontal : Array of children, from left to right horizontally Button1 Button2 Button3 [ vertical ] Button1Button2Button3 [ horizontal ]

33 2. Linear Layout LinearLayout Layout/Horizontal <LinearLayout xmlns:android=http://schemas.android.com/apk/res/androidhttp://schemas.android.com/apk/res/android android:orientation=“horizontal” android:layout_width=“fill_parent” android:layout_height=“fill_parent” > Layout/Horizontal3 <TextView android:layout_width=“wrap_content” android:layout_height=“wrap_content” android:text=“@string/insa” android:textColor=“#ff0000” android:textSize=“20pt” android:textStyle=“italic”/> Layout/Horizontal2 <TextView android:orientation=“horizontal” android:layout_width=“fill_parent” android:layout_height=“wrap_content” android:text=“@string/insa” android:textColor=“#ff0000” android:textSize=“20pt” android:textStyle=“italic”/> [ Horizontal ] [ Horizontal2 ] [ Horizontal3 ]


Download ppt "You have to remember that  To create an AVD(Android Virtual Device)  The Structure of Android Project  XML Layout  The advantage of XML Layout  Android."

Similar presentations


Ads by Google