How to fix hit area after scaling

by Jonathan » Wed, 12 May 2010 03:52:59 GMT


Sponsored Links
 I am scaling the canvas of a linear layout on draw, but this throws
off all the hit areas of my views inside of this layout. They respond
as if there was no scaling taking place. What do I have to do to get
themselves to re-register their hit areas?

Thanks

Jonathan

--



How to fix hit area after scaling

by Jason Tomlinson » Wed, 12 May 2010 20:55:13 GMT


 You need to scale your hit areas to match the canvas scaling.  If you
zoom in 2x on the canvas your hit area is now twice the size likewise
if you zoomed out 2x then your hit area is half the size.




>


Sponsored Links


How to fix hit area after scaling

by Jonathan » Thu, 13 May 2010 02:03:29 GMT


 Right, thats what I am trying to figure out how to do. I currently
don't know how to separate a hit area from an actual view.

It would make sense to me if there was some function needed to be
called that would then figure out the new bounds of the views and
change their hit areas appropriately. I am calling invalidate on the
parent layout, but that doesn't seem to do anything to the views
themselves. I'll try calling it on each child and see if that makes a
difference.




> >



How to fix hit area after scaling

by Jonathan » Thu, 13 May 2010 07:12:20 GMT


 Just in case anybody else wants to accomplish this, all you have to do
is override your child view's getHitRect method to account for your
parent view's scale transformation.

I'm not sure why the base view class doesn't do this automatically,
but I'm sure there is a reason.





> > >



Other Threads

1. Android on Galileo

Hey,
Is it possible to develop for Android on Eclipse Galileo? or we have
to stick with Eclipse Ganymede now days?
Thanks.
--~--~---------~--~----~------------~-------~--~----~

2. Alarm Manager

Hi

I have 2 problems,

I create a timer using AlarmManager and I set an Intent with certain
values in the putExtra methods and then create the pendingIntent with
this intent and call alamarmManager.set(RTC_Wakeup, time,
pendingIntent)

1.  The first time I do this everything works fine. The second time I
do this and use a intent with different data in the intent when the
alarm gets fired in my BroadcastReceiver class the data on the intent
is the data of the intent used in the first alarm and NOT the second
one.

2. If I call the alarmManager.set 2 times with 2 differents intents
and settings only the last alarmManager.set seems to result in my
broadcast receiver getting called. Does anyone know how to create
multiple alarms?

Here is my code I use to create the alarms

Intent i = new Intent(getApplicationContext(), ReminderAlarm.class);
i.putExtra(ReminderDbAdapter.KEY_ROWID, extras.getLong
(ReminderDbAdapter.KEY_ROWID));
i.putExtra(ReminderDbAdapter.KEY_TITLE, extras.getString
(ReminderDbAdapter.KEY_TITLE));
i.putExtra(ReminderDbAdapter.KEY_BODY, extras.getString
(ReminderDbAdapter.KEY_BODY));
Log.d("Sending", extras.getString(ReminderDbAdapter.KEY_TITLE));
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, i,
0);

AlarmManager alarmManager = (AlarmManager) getSystemService
(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, lcal, pendingIntent);

--~--~---------~--~----~------------~-------~--~----~

3. Is there a way to access the serial device on G1

4. Progress Dialog When Application Starts

5. Wrapping onCreateInputConnection for 1.1 safety

6. Android port for OMAP3 with GStreamer integration

7. How to Access PreferenceGroup from the code?