How to make a button in android and make it invisible - android-widget

I want to have a button which should not be visible but when clicked onclick should be executed..
I have tried making
Button button;
1)button.setVisiblity(4);//it made it invisible but onclick was not working
2)In the layout xml i have attached android:visibilty="invisible" //but it made it invisible

Remove the visibility bit and use the following instead.
button.setBackgroundColor(Color.TRANSPARENT);

Related

UI Button doesn't disappear when deactivating parent in hierarchy

I'm trying to write a simple main menu page with this hierarchy:
MainMenu (an empty game object)
↳ Canvas
↳ PlayButton (a TextMeshPro Button)
I want the button to deactivate the 'MainMenu' object in the hierarchy when clicked, thus hiding its Canvas child and the Button along with it. To do this, I'm providing the MainMenu object reference to the Button's OnClick() callback and calling 'GameObject.SetActive' to false when clicked.
My problem is that when I click the button, the MainMenu hierarchy get grayed out in the editor but the Button sticks around with its yellow Highlighted color shown. It does disappear if I change the display resolution while still in Play mode (maybe forcing a refresh?), but I can't figure out why deactivating the MainMenu wouldn't make it refresh in the same way.
I've tried calling SetActive(false) on the PlayButton and the Canvas themselves- I also tried setting enabled = false on them, but the Button appearance behaves the same. From everything I've read, calling SetActive(false) should hide whatever gameObject I call it on, so I can't figure out what I'm missing.
Alright, found my own mistake. The Camera's Clear Flags setting was Don't Clear, so even calling Destroy(gameObject) on it didn't remove it from the screen.
Setting the Camera to use ClearFlags: Solid Color fixed the problem.
It looks to me like you have a button in your grid that is displaying. When the game is playing, after you click to turn off the button, go to the scene tab, click the yellow button and see where that object is.
If in doubt (For testing purposes only) delete the button on click and if you see something else then it is obviously not that button.

Button obscured by another Button can't be pressed

There are 2 buttons - Button A and Button B.
Button B is situated on top of Button A.
Button B has it's Button Component removed.
I want the user to be able to click on Button A even though Button B obscures it.
How can I achieve this?
Not sure What is your question but if you want to click start button while air button is above it. you should disable the option on button called Interactable and also uncheck the toggle in image component of that button called Raycast Target. and that will do it.
Of course Button B button will block the one underneath it. Because Image component and Text and/or other Image component that button has blocks raycast to the button underneath of it.
You can do one of the following:
Remove your Button B button, because if it's not doing anything and actually interferes with a behavior you want then why have it in the first place? Think about it
Uncheck Raycast Target in your Button B button's Image component
Disable Image component of Button B button altogether
Thinking about first item on the list will benefit you greatly.
If you want a solution then use second or third option on the list, but bare in mind that unchecking Raycast Target or disabling Image component of your "Air" button still leaves an Image and/or Text as a child of aforementioned button that CAN and WILL block raycast to your Button A button.

How can i make a moving button in GWT, so that users can move it to anywhere they want?

I just want to make a moving button , Is there a way to do that in GWT? Thanks in advance.
BS
Out of the box, you can use a DialogBox to display your button. DialogBox can be moved around, but you will need to display something in a Caption that is used for dragging.
Another option is to use PopupPanel. It can be completely invisible (no Caption), but you will have to implement dragging functionality on your own. The advantage is that a PopupPanel floats on top of all the other layers in your UI.
Finally, you can simply add dragging functionality to a regular button. Just remember to check for the boundaries so that a user cannot drag your button outside of the visible browser area - or obscure some important elements of the UI.

Facebook Send flyout clipping issues

I have a problem with the flyout generated by the Facebook Send button. After clicking the "Send" button the flyout is generated and displayed behind some elements. Obscuring the buttons in the flyout.
I read that this is because of a parent element with the overflow:hidden style. However, I cannot remove this attribute since it will mess up the rest of my sites layout.
I tried to dynamically remove the overflow:hidden attribute upon clicking the Send button (Accepting the layout mess if someone actually uses the send button). Using the following code:
FB.Event.subscribe("message.send", function(response) { //Remove the
overflow:hidden styling here });
Unfortunately this event only fires upon actually sending the flyout form, which is too late as need to take action as soon as the button is pressed that shows the flyout.
Could anyone tell me how to bind an onclick event to the "Send" button or how to reposition the flyout completely. Or perhaps there is an alternate solution I have not yet considered.
Thanks in advance
Fixed position might work for some, but for most it will mess up your layout.
What worked for me is to take off any overflow: auto higher up in your CSS.
I did that and it works great!

how to do tooltip on button in iphone?

I am having download icon on my page i want that when the user takes his finger over the button a tooltip should show as showing download in text.
is there any option in iphone to show a tooltip???
Dan is absolutely right on how to do it but I'd answer you should rethink your design to not need the tooltip at all.
There's a reason that there isn't one by default - what if the user presses down on the button to see what it does, reads the tooltip and realises that's not what they want. They then have to be very careful not to let go while still over the button or it will press and do the wrong thing. (And most users don't know that they can press down over a button, move their finger off it and release it to cancel the press.)
You should rethink your design to make it obvious what the buttons do without the user having to interact with them first.
However, if you definitely still want a tooltip, Dan's method is fine.
Nothing built-in, no. If you think about it, generally a tooltip appears when you mouse over the target item. There's no "mousing over" with a touch interface.
You can definitely roll your own, though. Start by placing a view containing your tooltip contents exactly where you want it with an alpha of 0%. Make a custom button with no content that outlines your download icon, and hook its "touch down inside" action to a method that animates the tooltip view to an alpha of 100%. Hook your button's "touch up inside" , "touch down outside" and "touch up outside" actions (and maybe some others--you might want to experiment with that) to a method that animates the tooltip view back to an alpha of 0%.
There isn't native support for this in iOS. But you can create your own.
I ended up creating my custom tooltip/popover class.
Can be initalised with any content view and dynamically adjusts it's frame.
Hope it helps.
https://github.com/akeara/AKETooltip