Android Programming The Big Nerd Ranch Guide, 3rd Edition
597 31. Custom Views and Touch Events In this chapter, you will learn how to handle touch events by writing a custom subclass of ...
Chapter 31 Custom Views and Touch Events 598 Setting Up the DragAndDraw Project Create a new project named DragAndDraw. Select ...
Setting Up the DragAndDraw Project 599 Run DragAndDraw to confirm that your app is set up properly. It should look like Figure 3 ...
Chapter 31 Custom Views and Touch Events 600 Creating a Custom View Android provides many excellent standard views and widgets, ...
Creating BoxDrawingView 601 Next, update your fragment_drag_and_draw.xml layout file to use your new view. Listing 31.4 Adding ...
Chapter 31 Custom Views and Touch Events 602 Run DragAndDraw to confirm that all the connections are correct. All you will see ...
Handling Touch Events 603 This method receives an instance of MotionEvent, a class that describes the touch event, including its ...
Chapter 31 Custom Views and Touch Events 604 Tracking across motion events BoxDrawingView is intended to draw boxes on the scre ...
Tracking across motion events 605 Back in BoxDrawingView, use your new Box object to track your drawing state. Listing 31.7 Add ...
Chapter 31 Custom Views and Touch Events 606 Rendering Inside onDraw(Canvas) When your application is launched, all of its view ...
Rendering Inside onDraw(Canvas) 607 Listing 31.9 Overriding onDraw(Canvas) (BoxDrawingView.java) public BoxDrawingView(Context ...
Chapter 31 Custom Views and Touch Events 608 And that is it. You have now created a view that captures its own touch events and ...
609 32. Property Animation For an app to be functional, all you need to do is write your code correctly so that it does not cras ...
Chapter 32 Property Animation 610 When you display this oval in a square view, you will get a circle. People will nod their hea ...
Building the Scene 611 Now turn SunsetActivity into a SingleFragmentActivity that displays your fragment. Listing 32.5 Displayi ...
Chapter 32 Property Animation 612 Simple Property Animation Now that you have the scene set up, it is time to make it do your b ...
Simple Property Animation 613 The getTop() method is one of four methods on View that return the local layout rect for that view ...
Chapter 32 Property Animation 614 Figure 32.2 Setting sun You should see the sun move below the horizon. Here is how it works: ...
View transformation properties 615 shown in Figure 32.3), two properties to scale the view vertically and horizontally (scaleX a ...
Chapter 32 Property Animation 616 All of these properties have getters and setters. For example, if you wanted to know the curr ...
«
27
28
29
30
31
32
33
34
35
36
»
Free download pdf