• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Best widget/component to use?

TGT

Lurker
Hi all, this is a bit of a design/function query.

I'm not new to coding but new to android and not familiar with the options in the pallet. Doing a little 'virtual piano' app, I can't decide what to use to function as the 'keys'. So far I have got a simple setup where buttons trigger notes with onTouchListeners using ACTION_DOWN / ACTION_UP, but it occurred to me there may be a better component for doing this, though i'm not sure which, and am looking for a suggestion. Thanks!
 
Hi. Welcome to Android Forums.

Depends how you are trying to represent the keyboard. Using buttons is ok, but they probably don't look like piano keys, and it won't be possible to do a continuous glissando across the keyboard. Buttons are discrete up/down event handlers.
I'd probably do this by drawing the keys as rectangles, and detecting touch events within each area, or track the touch position of the finger as it enters/exits the area. More complex than your current implementation, but as I say, it depends what your aims are for this.
It's a good project though as it will expose you to a few areas of Android development, including 2D graphics.
 
Thanks LV426, that's what i was looking for. Having done some trivial stuff in Java with 2D a while back it sounds familiar, and I guess it won't be too different in this environment.

Cheers!
 
Back
Top Bottom