Android non-rectangular buttons, how to handle this? - android

I've designed some buttons with photoshop but now it came in my mind the problem on how make them work.
Basically I've this image
I've thought about two solutions: the first one is to place them in a RelativeLayout and place them with "lot" of padding/margin work, the second solution is to cut them vertically and attach them one by one, like this:
In the second solution I cannot probably use selector, not on all the button at least, not a big issue btw. With the first one I'm a bit worried about scaling on different screen sizes.
It will be a problem? Which solution would you suggest?
Thanks in advance.

Its not a must that your clickable area should be the same shape as your image shape..
Change the Image onclick...
If your options are open to use an image view instead of button, Then the whole image will be clickable.
I searched all over to find this question similar to yours.. Hope it helps.

Related

Animate view breaking in half crookedly

I am trying to make an animation with a layout which contains a background and some text (TextViews) inside it. The animation should make the whole layout crack in the middle and then move slightly like a paper tearing. So not along a straight line but a random zig-zag pattern along the middle of the layout from top to bottom.
I've been trying to find something like this so can I get an idea how to do this but have not been able to so far. Does anyone know how something like this can be done on Android?
TIA
You can try Brokenview Or ExplosionField.
Brokenview(https://github.com/zhanyongsheng/BrokenView).
ExplosionField(https://github.com/tyrantgit/ExplosionField).
Have you tried with this example? In the blog you have an explanation of how to achieve this behavior.
The idea behind is basically:
Save your Activity's screen as a bitmap.
Split it into two parts.
Animate the bitmaps outwards.

Button click on every single tooth...Making a layout that works for all screen resolutions

I have a jaw image as shown,,,i want that on every single tooth, there is a listener and succeded with that by adding button to every single tooth image by the relative layout but it works fine on one screen but gets disordered on the other.. how can i make it to work on all screen sizes?
Check out this article, I think the solution it presents suits your scenario well. Instead of solving this with some Android layout wizardry, you can specify a mask for your jaw-image that defines the clickable regions.
You can try out this, similar case.
Best of luck

Sliding drawer looks like semi circle

Android provides the SlidingDrawer by default looks like below image -
Image http://www.gru.at/android/wp-content/uploads/2010/09/s_open.png
Can we customize this SlidingDrawer looks like semi-circle type with buttons included. For, example take a look at below image -
Anyone done the SlidingDrawer like above one. I've googled it. Didn't get any nice solution for this. Anyone has idea/example blog for this?
So make sure you have Gimp and 9-Patch at the ready for a lot of trial and error...
Then what you wanna do is...
Add suitable layout to hold buttons where the current ImageView Handle is, like Horizontal LinearLayout or RelativeLayout
Cut the id of the current ImageView Handle and add it to this new Layout you just added
add your buttons to the LinearLayout/RelativeLayout (you can test it now, the buttons and the handle should all slide open at the same time)
Now add Button listeners for each of the buttons
Set the SlidingDrawer to android:allowSingleTap = "false" (tit for tat, you cant have the single tap option anymore, just the slide)
Use a ButtonSelector.xml to have different layouts for buttons be pressed or not pressed.
This is the hard part. Edit the drawables for the buttons, and handle so that they will fit together nicely if the screen is huge, small, landscape, portrait. I recommend using 9-Patch in conjunction with Gimp.
Pat yourself on the back because you now have a totally sweet custom sliding drawer.
Make sure you post pictures and state any problems or issues you ran into as I have never fully implemented this, but I did get to step 6 to make sure it was possible.
Last but not least, Good Luck...
Thanks for RelativeLayout and FrameLayout These layouts makes my requirement comportable with what i need. I've done like below steps -
First, i've splitted the full image into three pieces. And, merge these images with FrameLayout And, gave onclickListner to my center of image(Because, it was contain that arrow marks up/down)
And, i've used the Animation for just to open that View as SlidingDrawer
These steps helps me lot.

Create a button with custom layout android

Image comments: Icon should go centered in the red bit. The text should go centered in the yellow bit.
I'm trying to create a button in android that looks pretty much like the above. I tried with the imagebutton, the normal button (with drawabletop and drawablebottom), but the text is not proper aligned then.
Do note that I prefer not to use shapes, as the final result will be ninepatch images (that come from photoshop). Although feel free an example there for documentation use.
Also note that it needs to be clickable.
I think i just need to create a custom XML for this below, and then somehow have a button make use of this. I just haven't figured out how/where i need to set the text and so on then.
Any advice on this is appreciated.
hiii....
While using Button... you can align your text as per your expectations using android:gravity="center"android:text="TestHere"`
Try using this... In my case this works f9... It does or doesn't help you plz let me know
You could create the lower part as a separate button, and the above part as an imageview. In your layout file, place the top part above the bottom part. And finally, in your code, create a on clicklistener and assign the same listener to both the button and the image. Of course this would only cause the bottom part to act like a button(looking like it's pressed), but perhaps that's acceptable.
As you want to use Nine patch, create nine patch such a way that the content area is only in the middle of the yellow portion. I'm sure you know how to select content area for nine patch.

creating a custom image based layout on android

Is it possible to create a layout based on (background) images? For example, there is well know app called Appie that uses this picture as a homescreen:
I might be able to recreate the layout with a TableLayout, but this will be difficult to get it perfectly aligned with the buttons in the image. The default layout options make it very difficult, or maybe impossible, to allow for selection of the buttons on the image (especially when the buttons are in an arc-path).
Can anyone tell me how this is done?
I had some issues positioning a badge on the corner of a view. You can check my solved question:
Positioning a badge bubble on the left upper side of a button
About how it can be done. I would do it with a RelativeLayout and TableLayout as you mentioned, but to be completely sure, you can use apktool to see how the xml are done but it might be ilegal to do it.

Categories

Resources