I am creating a news app which contains a 'share news' button. Currently this button is showing all the time when user reads the news, which makes news reading irritating. Now my question is how can I make that share button show up when user touch on the screen, and will disappear after 2-3 seconds if it is left without touching. It would be nice if I can make a little animation during the button appearing/disappearing (like, show up from bottom and disappear going down). Please help...
Thanks
add an on touch event on your view and change visibilty of your button visible when touched after that start an timer using handler for three seconds and set visibility gone there after three seconde for handler code check this answer
Running a thread for some seconds
Related
I am experimenting with Transition animations following the Android Documentation here. I have a small POC where an ImageView and TextView are animated once the user clicks a button, as shown in the recording below.
This is working fine.
However, what I'm struggling to figure out next, is rather than triggering the animation with a click event, I would like the views to respond to continuous user input, such as dragging a Seekbar, and animate accordingly. So basically, if I drag the Seekbar let's say until mid point, then the views would perform only half of the animation and stop.
Any tips where should I look into, in order to achieve that?
I'm developing an Android app that basically is a game. In the main activity there is a button to start playing and other buttons that are also part of the game, but if the user presses any button other than to start, a Toast is displayed asking him to press the start button. The problem is that he can press other buttons several times, flooding the screen of Toasts that repeat the number of times they were requested.
The desirable thing is that there was no queue at all, that is, the Toast would only be displayed if there were no other Toast on display.
P.S. Leave buttons invisible or disable click are not options.
Hi there is thery any way to invoke a method that enables or disables the Touch Screen of Android?
I want this, because I have several buttons on my activity. When the user clicks on a button, it takes a few seconds to start the following activity, and because of that, while waiting that time, I don't want the user to be able to press anything.
I used a boolean that is True at start, then It changes to false when I click on the first button. And to every click on a button I check if the boolean is true...
But the problem is that Visually the user can click the button, it gets that look of being pressed..
So is there any good method that disables the entire touch screen ? And another that enables the entire touch screen ?
Thanks alot in advance ;)
But the problem is that Visually the user can click the button, it gets that look of being pressed
Disable the buttons, using setEnabled(false). This will not only prevent the user from clicking on them, but they will visually appear disabled, to let the user know that the user cannot click on them. It is important for the user to get the proper visual feedback about the buttons being disabled (and later enabled).
is thery any way to invoke a method that enables or disables the Touch Screen of Android?
Not really.
I want to create a button which will be shown on top of all apps.
something like this
as you can see, there is a button at top left corner. it can receive touch events and touch events can be received outside it by other apps.
I tried to use Theme.Translucent.NoTitleBar to my activity but it does not helped. I also set size to my button to [100, 100] but other activity behind it can not receive touch events. I think that the problem is in activity's window. it's size does not equel activity's size.
any help please
UPD
solved
hatcyl in Create a UI or a widget that sees on top of all Application in Android? says:
If you want something to be clickable, you can display it on top of
anything except the lockscreen.
You would to use a service and WindowManager to show a button on every App.
I'm working on an app which presents users with four buttons and a timer. The users then tap as fast as they can, each user on his own button, and the one with the most taps at the end wins.
I can't use onClick here, because it locks up the UI thread until the button is released, effectively blocking other button presses. I have searched around for a bit and found that I could use onTouch, but it doesn't work the way I want it to. If a user has touched and is still holding a button, any subsequent touches on other buttons will behave as though this first button was pressed.
Someone suggested the use of an image, transparent and stretched across the entire visible UI. One could then read any touches on this imageview and assign a touch to a particular button based on the coordinates of the press. (I guess I would take a screenshot of my UI with the four buttons visible, open it in paint and write down the coordinates of the borders for each button, then use those coordinates in the code to figure out which button the user was trying to press.)
Can anyone help me with this method of work, give me a quick example, or link to where I can learn how to do it and implement it in my app? It would be much appreciated.
TL;DR: How to use an image, transparent and stretched across the entire visible UI and read the coordinates of each press (even if multiple at once)?