Positioning after rotation.

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Positioning after rotation.

Postby forsan » Wed Jan 06, 2010 3:05 pm

Im fairly new to programing android apps and i thought id make a timer, however im having some trouble rotating the clock as it ticks down. At first i created a new bitmap with a new rotation but it was way to slow and way to laggy when im suposed to hold it and spin it around in realtime so i wrote this witch removed the lag compleatly and the rotation is working but it positions it at the top left corner.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public void setClockRotation(double rotation) {
  3.  
  4.  
  5.  
  6.     ImageView image = (ImageView) findViewById(R.id.clock_spin);
  7.  
  8.  
  9.  
  10.     Matrix m = new Matrix();
  11.  
  12.     m.postRotate((int)rotation);
  13.  
  14.     image.setImageMatrix(m);
  15.  
  16.     System.out.println(rotation);
  17.  
  18. }
  19.  
  20.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


is there a way to reposition it to its right position again?
forsan
Freshman
Freshman
 
Posts: 9
Joined: Wed Jan 06, 2010 2:36 pm

Top

Postby Draffodx » Wed Jan 06, 2010 4:16 pm

The item (clock) referenced by R.id.clock_spin is in the top left hand corner of the screen is this what you mean?
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Postby forsan » Wed Jan 06, 2010 4:48 pm

yes.

It should be in the center of the screen and it is on startup but when i want to rotate it through this function it places itself in the top left corner of the screen.

EDIT:

Here is a pic that i hope helps to understand what im asking.

http://img138.imageshack.us/img138/2419/clocky.jpg
forsan
Freshman
Freshman
 
Posts: 9
Joined: Wed Jan 06, 2010 2:36 pm

Postby Draffodx » Wed Jan 06, 2010 6:21 pm

in your xml layout file make sure you have the position set to center the image
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Postby forsan » Thu Jan 07, 2010 11:36 pm

I have that and it is on the right position in the begining but as soon as i try to rotate the clock it jumps to the top left corner.
forsan
Freshman
Freshman
 
Posts: 9
Joined: Wed Jan 06, 2010 2:36 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests