Disable onClick sound for a View - java

I'm using a LinearLayout (with some views inside) for representing the sound On/Off button in the Settings screen.
When I set the OnClickListener to this Layout it automatically plays the system "onClick" sound when clicked.
I'd like to play the sound only when the sound is going from 'NoSound' to 'Sound'. How can I supress the sound in the other case?

Have you tried using setSoundEffectsEnabled(false/true); which should work as per documentation that
Boolean that controls whether a view should have sound effects enabled
for events such as clicking and touching.

Related

How to make overlay receive touch events without consuming the touch for the other apps?

I'm currently trying to make a utility overlay similar to Facebook Messenger chatheads in which you can move the view around the screen. When you click the view, it expands into a more complex layout. However, the problem is if I set the LayoutParams' flag to WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, the apps behind receive the touch events while my overlay doesn't receive any touch events at all. But if I remove that flag, the overlay receives the touches but it blocks the touch. Meaning I can't even open the app drawer since the touches are being blocked.
I am using a fullscreen transparent Activity as background so I can move my overlay "widget" around it.
Is there any way I can make it so that it doesn't block touch events. Even if I don't set it to fullscreen, as long as I don't have the FLAG_NOT_TOUCHABLE flag, my overlay completely blocks all screen touches.
Please Remove this flag
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
with this flag
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
see this link https://medium.com/#kevalpatel2106/create-chat-heads-like-facebook-messenger-32f7f1a62064

Android - How to implement water ripple effect on button click?

so I am trying to implement something like a ripple water effect on an Android app where I can click only on a button and the ripple would affect everything that is currently displayed except the clicked button.
I don't really know how to start, any suggestions?

know pointer number on screen

I develop a simple Android app, and I want to know how many fingers is touching the screen. It's simple with OnTouch event but this solution doesn't work if the user touch the keyboard software (for security and privacy issues)
I have tried to use a specific overlay like this : Creating a system overlay window
It work, the onTouch event is called everytime, everywhere, but the overlay block all the touch event and the app is unusable (touch button, write with the keyboard software, all interaction doesn't works)
How can I receive touch events on my overlay and on my others view behind this overlay ?

Zoomable android widget with VideoView component

There is compound widget which consists of VideoView and Button. VideoView play video, Button handle events. I'm struggling how to make it resizable according to pinch gesture.
Unfortunately, it is not possible to add pinch zoom to widgets, since there is no way to add event listeners to widgets. The only way a widget can receive input is assigning on click intents to different components, which start activities. As for videos, look into the VideoView class, although AFAIK this doesn't work well (if at all) with widgets.

Android Button background Image changes back to state in XML

I have a simple soundboard which uses Buttons to represent the sounds. When a sound button is clicked. The background image is changed using the view.
Button butt = (Button)view;
butt.setBackgroundResource(buttons_on[media]);
buttons_on is a int[] representing the drawables of the buttons.
This all works perfect, but I also use a FragmentActivity to create a paged App. The App has 4 different pages which you can swipe through. When I change a button using the above code and swipe two pages to the right and than swipe back. The image of the button has changed back to it's default defined in the page.xml.
How can I prevent this behavior?
change the Buttons to ImageButtons and setting the src?
somehow prevent the page from reloading
Instead of doing that you should look at how to use a StateListDrawable. It will simplify your approach.

Categories