Android: custom button shape - android

I'm trying to achieve a custom controller containing of various buttons in different shapes. I'm wondering how I can achieve this with Android.
The result should look similar like this, where every color is a different button.
I suppose I have to subclass View so please don't write that as an answer ;-) Please give some methodical steps what's needs to be implemented, like drawing, sensing touches, etc or maybe point me to some examples (if exist).
Thanks

if you intend to draw this dynamically you would have to extend View and override onDraw, you can implement onTouchListeners, etc to detect when and where people are touching it.

I found this document explaining everything in detail and having links pointing to related topics.

Related

Android Layout Design Specific Custom

I am Stuck at place where i want to developer custom layout in android, please Suggest that how can i achieve layout like this which technology should i use , I want to develop application like Booking of Seats in bus or Some thing like that Please Guide which way i go like on XML,openGL , Canvas Please guide me
If you need to interact (handle click or touch) with every view marked with a number I would strongly recommend using XML. Using OpenGL or Canvas would add plenty of time to achieve a good interaction. Creating your layout in XML will be the hardest part, but after that you'll be able to interact with every view setting regular View.OnClickListener or TouchListener.
Hope this suggestion helps.

onTouch event on Android Games

my question is not only about onTouch events but about every method I can use to recognise a touch on certain areas of the screen.
Right now, I have a "background" image, which I use as layout that contains 2 "buttons": Start and Options as you can see here:
Ok, what I want to know is which is the best way to identify when are the user touching each button. By the way, should be nice also some info about how to deal with the different screen sizes.
Lots of thanks.
PD: seems I didnt explain it well. they are not "Android buttons" theirselves. The background is a whole image, where you can find 2 "buttons", but they are a part of the image. Thats because I need to know how to do this
I think you're missing some fundamentals, so I recommend to take a tutorial track.
As a direct answer to your question , you can see this page from the tutorial.
Why do you want to set the touchListener on whole screen and find the buttons?..You can simply set the OnClickListener or onTouchListener on both the buttons itself..

Android Custom Buttons: Alternative to Multiple Graphics?

I think all custom button tutorials I have been able to find for Android assume you are using three images for your button: a normal image, a pressed image, and a focused image.
Instead of essentially tripling the size of a given button's resources (and creating more work for the artist/UX guy), is it possible to only supply a normal button image, and for the other states, draw some sort of overlay over the existing button by extending the Button class?
Has anybody tried doing this with any success, or is it just accepted that all custom buttons need an image for each state and that is that?
You could by overriding the draw methods of the view in your custom button but it would be a simple process as you would have to also identify the different states yourself.
I think the correct answer to this question is essentially what #Luksprog said in the comments... It simply isn't worth it. Just make the extra art.

Creating a custom ui element and making it respond to user input

I have a volume knob and would like to know how to make it respond to user input in android. Please point me in the right direction as i have no idea how i can go about it ? Custom Knob looks like something created in this article. My question is what would be the general approach to port this knob into an android application. Do i have to extend the view class and draw this as a Bitmap. If so how exactly would i respond to user input. If this is not possible and i am on the wrong track could someone please tell me how to achieve this?
I would extend the View class.
View is the baseclass for widgets in android (by widgets I mean textfields, buttons, etc), so I think a volue knob would fit right in among those. About the user input, I'm not so sure. I think it depends on how you want to control the knob. I think looking at the onTouchEvent(MotionEvent) would be a good start. My guess is that you will need to overload a similar method anyways.
Related links:
http://developer.android.com/reference/android/view/View.html
http://www.vogella.com/articles/AndroidGestures/article.html

Small Popup for Instructions, like foursquare ones

After seeing the last screenshots of new foursquare application and their balloon like cartoon instructions, I'd like to create some of these in my application.
I found a similar question for iPhone
Small popup for instructions... How?
Here is another screenshot of foursquare app:
I'd like to know how I could achieve that with Android.
Thanks in advance for any help.
UPDATE: This is what I could get so far but adding some buttons with a custom drawn background and layering them with a FrameLayout:
But I still couldn't get the triangle effect. Maybe there is something I can do with my custom background shape?
UPDATE2
After checking your suggestions, I decided to go with Aaron C idea and added an image with an arrow on it. This is my current result:
Thank you Snailer, QuickAction API project seems very much promissing. I'll check it out when implementing more features in my app.
Now, I just need to get the right color or maybe I could just let it this way. It seems nice too.
And, so, to summarize what I did:
Got my initial xml layout inside a FrameView.
As I'm using a frameview, everything I put in here will be piled one over the other. That's how I could add things to the layout.
In that framelayout, I put 2 relativelayouts whith an image with the triangle and a button to create the two upper popups. In the bottom I put a button only.
That's it. I hope it helps somebody.
Thank you very much again for all your help!
That sounds like a neat thing to implement. There might be a built-in Android variation on AlertDialog that achieves this, but if not here is how I would go about implementing it:
Create a new Activity whose background is black with a very high (low?) alpha color value. This will allow you to see through it to the previous Activity in the stack. Then, add your alert at whatever coordinates you like using a relative layout with padding values.
You might also want to add a touch listener that exits the Activity if the user touches the balloon (or maybe anywhere in the screen).
If you want to be fancy with coordinate placement of the balloon, you can pass this information into the new Activity using the Activity's launch Intent with the putExtra() methods.
It's probably achieved through skinning a toast.
The developer documentation shows a skinned toast in "Creating a custom toast view" at http://developer.android.com/guide/topics/ui/notifiers/toasts.html
You may want to look at the QuickAction API. It acheives this by using PopupWindow, skinned, positioned, and animated.

Categories

Resources