Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2
This is the forum to discuss the Wrox book Professional Android Application Development by Reto Meier; ISBN: 9780470344712
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 7th, 2010, 07:13 PM
Registered User
 
Join Date: Apr 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 10: Compass

All works except the actual compass on the outside. When moving the phone around the two circles in the center react right. The outer compass however doesnt move to the correct position and instead just wiggles. It stays with North at the top and wiggles when the phone is moved. Extreme movements seem to get it to react more, but it always returns to its original position.

Is the placement of this code in the correct place, before the for loop?
Code:
protected void onDraw(Canvas canvas) {
    int px = getMeasuredWidth() / 2;
    int py = getMeasuredHeight() / 2 ;
    int radius = Math.min(px, py);
    
    // Draw the background
    canvas.drawCircle(px, py, radius, circlePaint);
    // Rotate our perspective so that the 'top' is
    // facing the current bearing.
    canvas.save();
    canvas.rotate(-bearing, px, py);
    int textWidth = (int)textPaint.measureText("W");
    int cardinalX = px-textWidth/2;
    int cardinalY = py-radius+textHeight;
        
    // Draw the marker every 15 degrees and a text every 45.
    for (int i = 0; i < 24; i++) {
Complete code
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 10, listing 10-10-app kiwibrit BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 2 August 18th, 2009 04:21 AM
Chapter 4 Compass background color eags BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 1 January 10th, 2009 01:07 PM
Chapter 10 czambran BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 March 29th, 2005 09:35 AM
Chapter 10 columbiasmiles JSP Basics 0 May 17th, 2004 08:09 PM



All times are GMT -4. The time now is 04:02 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.