i want to create an screen efect like when you take an screenshot in the phone, i mean, a little flash in the screen when i click a button, also i want to change the color of that flash. Is that posible? thank you very much in advance ;)
Press the Power and Volume down buttons at the same time. If that doesn't work, press and hold the Power button for a few seconds. Then tap Screenshot. If neither of these work, go to your phone manufacturer's support site for help.
As long as you're running Android 12, you can use a unique swipe gesture to take a screenshot on the Pixel 6. All you need to do is swipe up from the bottom of the screen and hold your finger on the screen for a second. This will open your app drawer, where all your recently opened apps appear.
An easy way to get this effect would be to have the following:
Create an empty 'panel' over your layout. For example:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<!-- Your normal layout in here, doesn't have to be a LinearLayout -->
</LinearLayout>
<FrameLayout
android:id="@+id/pnlFlash"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="[Set to your desired flash colour, image, etc]"
android:visibility="gone"
/>
</FrameLayout>
The FrameLayout with the id 'pnlFlash' remains hidden away so it won't interfere with normal interaction.
Now when you want to make a flash all you have to do is make the panel appear for as long as is appropriate. having a nice fade off always helps too.
pnlFlash.setVisibility(View.VISIBLE);
AlphaAnimation fade = new AlphaAnimation(1, 0);
fade.setDuration(50);
fade.setAnimationListener(new AnimationListener() {
...
@Override
public void onAnimationEnd(Animation anim) {
pnlFlash.setVisibility(View.GONE);
}
...
});
pnlFlash.startAnimation(fade);
I haven't used this kind of code before for a flash so you might want to tweak the duration accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With