Android: Create diamond button with icon and text inside - android

I would please like to know how to create a diamond shaped button with an icon and text inside. Like in the image below. If i rotate the button then the image and icon get rotated too and if I create a custom shape/image to use as the background the buttons clickable area is still a square. Any help would be appreciated?

if you want change clickable area you have to intercept touch events and filter them. You need custom view for doing this

Related

Add text in the corner of a button Android

I have a quick symbol bar with a few buttons. I want to place a symbol in each corner of the button in addition to the button text. My goal is that when the user press the button then drag his finger in one of the corner direction, the symbol in the corner is inserted, like in Quoda app. Here's a quick sketch:
How can I write in the corners of the button programmatically?
For the second part, I guess I could do it this way: I calculate the x,y difference from the center of the button at the release then insert the right symbol.
EDIT: I cannot use a ImageButton and a drawable background, because I want the symbols to be customizable.
Try create custom compound component based on RelativeLayout with ImageView's (You can also use VectorDrawable's) in center and corners like in this tutorial.

Android ImageButton - How to hide the image while showing the background?

I've read the API and Googled but perhaps I've missed something: All the visibility options on an ImageButton seem to talk about this view as a whole. So, what should I do if I want to hide the image but keep the background(except for explicitly setting the image to something transparent that is)? I'm doing a Pairs Game and when one clicks on the element it should show the image and if the next click doesn't match the image should be hidden, but the grey background of the button should remain.
Thanks!
So, what should I do if I want to hide the image
Try setting it to #null or create transparent PNG in your drawables and set it.
in XML, remove android:src="something" and in the code remove imgbtn.setImageBitmap(null);
Instead of using ImageButton you can use ImageView with a FrameLayout on top of it. Set the background of FrameLayout as gray color and then show/hide this FrameLayout/Image as per your requirement. Take relative layout for each and make it clickable. On the click event of this layout, do the changes as required.

how to click Background and something should happend?

I want to click the Background of a layout (not clicking anywhere, for example in the top right) and then reproduce a sound, can i put an empty View and put an On Click to that? I think is not possible.
If is possible, there is a better way?
I want to put some invisible "buttons" at the Background because I will put an image Background with shapes, that's why It couldn't be anywhere.
Thanks and sorry for my english.
You can put a button on the right corner and apply an empty or simply transparent image as icon button.
In this way, you can choose a different behavior for each screen position.

How can I do when button focus on image another image appear

I already have designed menu bar circle layout and wheel menu for android application. it is scroll circle . But I want this
1) When button comes on image ( focus red circle ) it should be clickable
2) when button hover on image ( focus red circle ) it should be show another image
how can I understand which button focus on image.
I put picture.First picture; when button two hovering red circle second picture appear, and another image showing. Which library should I use. Do you know any project open source code?
sorry my bad english.
You can use the arcMenu or the android Clickwheel layouts.
Check thse links for additional details:
ArcMenu
ClickWheel

what is use of image button?

I'm new to Android application development.
I would like to ask the use of image button in Android programming when simple button can also add the image with the button. How can we generate click event of image button?
The Image Button control is a special type of button that displays a Drawable graphic instead of text.
The Image Button and Button controls are both derived from the View class, but
they are unrelated to each other. The Button class is actually a direct subclass
of Text View (think of it as a line of text with a background graphic that looks
like a button), whereas the Image Button class is a direct subclass of Image View.
If you will look in the API for Button you will see that it has a method called setOnClickListener that is inherited from View. Since ImageButton is also a view, you can also call the same method for it.
The only way that I see to use an image in a Button is by using android:background in the XML. This is only used for setting what's shown behind the text of a button. You should use ImageButton when you want to make a button that only uses the image as its defining feature. If you end up wanting to only see the image and have no part of the button background visible, you can set android:background on the button to use an invisible Drawable.

Categories

Resources