• Complain

Komatineni Satya - Expert Android

Here you can read online Komatineni Satya - Expert Android full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. City: Berkeley;CA, year: 2013, publisher: Apress, Imprint, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Komatineni Satya Expert Android

Expert Android: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Expert Android" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

From the leading publisher of Android books, Apress Expert Android gives you advanced techniques for customizing views, controls, and layouts. Youll learn to develop apps in record time using JSON, Advanced Form Processing, and the BaaS (Backend As A Service) platform Parse. The book also includes extensive coverage on OpenGL, Search, and Telephony. With these advanced and time saving technologies youll be able to release compelling mobile applications in Google Play and the Amazon Appstore at a rapid pace. In Expert Android, youll learn to: Borrow, reuse, or build custom Android UI components Create 3D experiences using OpenGL ES 2.0 Write collaborative applications in the Parse cloud and communicate with your app user community through Parse Push Technology Reduce the time-to-market while creating rock solid apps for multiple devices Whether you are an individual or enterprise developer, in Expert Android youll find the advanced techniques and practices to take your mobile apps to the next level. Regardless of the Android release, this book serves as your definitive, capstone reference for your Apress Android experience.

Komatineni Satya: author's other books


Who wrote Expert Android? Find out the surname, the name of the author of the book and a list of all author's works by series.

Expert Android — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Expert Android" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Satya Komatineni and Dave MacLean Expert Android 10.1007/978-1-4302-4951-1_1 Satya Komatineni 2013
1. Exploring Custom Views
Satya Komatineni 1 and Dave MacLean 1
(1)
Florida, USA
Abstract
Your understanding of Android SDK is not vigorous until you master the architecture of Android's Views. So it is appropriate that we begin Expert Android by exploring the power of Androids custom views. Our goal in this and the next two chapters is to unwrap the architecture of Androids Views by customizing them. In Android you can customize views in three ways:
Your understanding of Android SDK is not vigorous until you master the architecture of Androids Views. So it is appropriate that we begin Expert Android by exploring the power of Androids custom views. Our goal in this and the next two chapters is to unwrap the architecture of Androids Views by customizing them. In Android you can customize views in three ways:
  • Custom views (by extending the View class)
  • Compound views/controls (by composing other existing controls through extending one of the existing Layout classes) (Note that in this and the next few chapters we are using custom views and custom components synonymously)
  • Custom layouts (by extending the ViewGroup class)
We have learned a lot in researching each of these topics. We are eager to share with you this information on custom components, presented in this and the next two chapters. We believe custom components hold the key to unlocking the full potential of the Android SDK.
We start this chapter by covering the custom views. This chapter also forms the basis for the next two chapters: Compound views/controls and Custom layouts.
To demonstrate custom views, in this chapter we:
  • Create a custom view called CircleView and explain the theory and mechanics of customizing a View .
  • Present the entire source code of CircleView in order to guide you to write your own custom views.
  • Show how to embed the CircleView in any of Android layouts.
  • Show how the CircleView responds to touch events by changing the size of the circle. (Note that we are using click and touch synonymously in much of the book!)
  • Show how the CircleView remembers state (such as the size of the circle) as you rotate the device.
  • Show how to use custom attributes in layout files to initialize the CircleView .
Planning a Custom View
Before we explain the implementation of a custom view like the CircleView , let us show you the expected look, feel, and behavior of the CircleView . This, we believe, will make it easier for you to follow the subsequent explanation and code.
Lets begin by examining the CircleView in Figure , the CircleView is between two text views in a linear layout. The width of the view is set to match_parent . The height of the CircleView is set to wrap_content .
Figure 1-1 Custom CircleView with wrapcontent When we design this - photo 1
Figure 1-1.
Custom CircleView with wrap_content
When we design this CircleView , we make the circle stroke color and width configurable in the layout file using custom attributes. To test responding to events, we use click events to expand the circle and redraw. Figure shows what the CircleView would look like after a couple of clicks. Each click expands the circle by 20 percent.
Figure 1-2 Custom CircleView expanded with clicks We then implement state - photo 2
Figure 1-2.
Custom CircleView expanded with clicks
We then implement state management to the CircleView so that when we flip the device to landscape, the view retains its magnification. Figure shows the rotated device with CircleView maintaining its expansion.
Figure 1-3 Custom CircleView retaining state after rotation Lets get - photo 3
Figure 1-3.
Custom CircleView retaining state after rotation
Lets get started and cover all the essential things (there are a lot of them) about custom views so that you can design and code the CircleView that is shown in Figures .
Nature of Drawing in Android
To understand how to draw in Android, you have to understand the architecture of the following classes:
View
ViewParent (interface)
ViewGroup (extends View and implements ViewParent)
ViewRoot (implements ViewParent)
View is the fundamental class that all of the visible components in Android are derived from. It defines a number of callbacks to customize its behavior, like the ability to define size, draw, and save state.
A ViewParent defines the protocol for any object (including another view) that wants to play the role of a parent to other views. There are two important view parents. Of those, ViewGroup is the key one. In addition to being a ViewParent , a ViewGroup also defines the protocol for a collection of child views. All layouts like the FrameLayout and LinearLayout in the Android SDK extend this class ViewGroup . ViewGroup plays a central role in defining these layouts in XML files and in placing the controls (views) at the right place. A ViewGroup also controls the background and animation of its child views.
The other key ViewParent , the ViewRoot is implementation centric and is not a public API. In some releases it is called ViewRoot , and in some implementations it is called ViewRootImplementation and it may even be changed in the future to something else. However, this class is important for understanding how drawing is done in Android.
We advise you to keep tabs on the source code of these three classes (View, ViewGroup, ViewParent) to refer back to, should you have questions that were not answered anywhere else. For instance, if you want to look up the source code for View.java , Google that name and you will see a number of places on the Web that has this source code. The source code may not match the latest release, but for understanding what this class does, it is sufficient. I tend to download the latest android.jar source code and keep it in eclipse, then quickly locate a file in the source using CTRL-SHIFT-R ( R stands for resource).
Being a root parent of all views in the activity, the ViewRoot schedules traversals of all the views in order to first lay them out at the right place with the right size; this is called the layout phase. The ViewRoot then traverses the view hierarchy to draw them; this phase is called the drawing phase. We will talk about each of these phases now.
Layout Phase: Measurement and Layout
The goal of the layout phase is to know the position and size of each view in the view hierarchy owned by a parent such as the ViewRoot . To calculate the position and size of each view, the ViewRoot initiates a layout phase. However, in the layout phase, the view root does a traversal of only those views that reported or requested a layout change. This conditional measurement is to save resources and improve response time.
The trigger to initiate the layout phase may come from multiple events. One trigger may be the very first time everything is being drawn. Or one of the views, while reacting to an event like a click or touch, could report that its size has changed. In such an event, the view that got clicked on calls the method requestLayout ( ). This call walks up the chain and gets to the root view ( ViewRoot ). The root view then schedules a layout traversal message on the main threads queue.
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Expert Android»

Look at similar books to Expert Android. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Expert Android»

Discussion, reviews of the book Expert Android and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.