Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)
31. Custom Views and Touch Events In this chapter, you will learn how to handle touch events by writing a custom subclass of Vie ...
Chapter 31 Custom Views and Touch Events Setting Up the DragAndDraw Project Create a new project named DragAndDraw. Select API ...
Setting Up the DragAndDraw Project Run DragAndDraw to confirm that your app is set up properly. It should look like Figure 31.2. ...
Chapter 31 Custom Views and Touch Events Creating a Custom View Android provides many excellent standard views and widgets, but ...
Creating BoxDrawingView Next, update your fragment_drag_and_draw.xml layout file to use your new view. Listing 31.4 Adding BoxD ...
Chapter 31 Custom Views and Touch Events Run DragAndDraw to confirm that all the connections are correct. All you will see is a ...
Handling Touch Events This method receives an instance of MotionEvent, a class that describes the touch event, including its loc ...
Chapter 31 Custom Views and Touch Events Tracking across motion events BoxDrawingView is intended to draw boxes on the screen, ...
Tracking across motion events Back in BoxDrawingView, use your new Box object to track your drawing state. Listing 31.7 Adding ...
Chapter 31 Custom Views and Touch Events Rendering Inside onDraw(Canvas) When your application is launched, all of its views ar ...
Rendering Inside onDraw(Canvas) Listing 31.9 Overriding onDraw(Canvas) (BoxDrawingView.java) public BoxDrawingView(Context cont ...
Chapter 31 Custom Views and Touch Events And that is it. You have now created a view that captures its own touch events and per ...
32. Property Animation For an app to be functional, all you need to do is write your code correctly so that it does not crash. F ...
Chapter 32 Property Animation When you display this oval in a square view, you will get a circle. People will nod their heads i ...
Building the Scene Now turn SunsetActivity into a SingleFragmentActivity that displays your fragment. Listing 32.5 Displaying S ...
Chapter 32 Property Animation Simple Property Animation Now that you have the scene set up, it is time to make it do your biddi ...
Simple Property Animation The getTop() method is one of four methods on View that return the local layout rect for that view: ge ...
Chapter 32 Property Animation Figure 32.2 Setting sun You should see the sun move below the horizon. Here is how it works: Obj ...
View transformation properties shown in Figure 32.3), two properties to scale the view vertically and horizontally (scaleX and s ...
Chapter 32 Property Animation All of these properties have getters and setters. For example, if you wanted to know the current ...
«
27
28
29
30
31
32
33
34
35
36
»
Free download pdf