android - How can I make a Button more responsive? -
i have noticed buttons don't seem responsive be. applies equally app , other apps i've tried.
when press button there tiny bit of lag (edit: estimate 20-50 ms) before button lights in pressed state. apps have managed remove bit of lag, instance realcalc (available in market) buttons switch pressed state after press finger on them.
most of time lag not noticeable, in case buttons used in custom number pad, tiny bit of lag disruptive user. realcalc feels more responsive , polished because lag has been removed.
my question - how remove lag? aware subclass, override ontouchevent , proceed there, prefer solution using standard controls , options. suspect solution may interfere scrolling, can live that.
edit: specifically, lag mentioned time put finger on button , hold there until button switches pressed state. onclick handler called when remove finger again.
some answers suggested moving bulk of onclick handler thread. not issue. make doubly sure, have removed click handlers, , tiny lag still there.
i have dug android source code see going on.
it turns out android.view.view class (from button derives) enters "prepressed" state before going pressed state:
android.view.view:
1529 /** 1530 * indicates prepressed state; 1531 * short time between action_down , recognizing 1532 * 'real' press. prepressed used recognize quick taps 1533 * when shorter viewconfiguration.gettaptimeout(). 1534 * 1535 * @hide 1536 */ 1537 private static final int prepressed = 0x02000000;
android.view.viewconfiguration.gettaptimeout() 115 ms on nexus one, lot longer estimation.
android.view.viewconfiguration:
67 /** 68 * defines duration in milliseconds wait see if touch event 69 * tap or scroll. if user not move within interval, 70 * considered tap. 71 */ 72 private static final int tap_timeout = 115;
anyway, examining view.ontouchevent doesn't there's way avoid prepressed state standard option. real shame.
the news have verified way avoid lag subclass , override ontouchevent.
thanks discussion , answers.
Comments
Post a Comment