Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 屏幕截图效果_Java_Android - Fatal编程技术网

Java 屏幕截图效果

Java 屏幕截图效果,java,android,Java,Android,我想创造一个屏幕效果,比如当你在手机上截图时,我的意思是,当我点击一个按钮时,屏幕上会有一点闪光,我还想改变闪光的颜色。有可能吗?事先非常感谢;) 获得这种效果的简单方法是: 在布局上创建一个空的“面板”。例如: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_widt

我想创造一个屏幕效果,比如当你在手机上截图时,我的意思是,当我点击一个按钮时,屏幕上会有一点闪光,我还想改变闪光的颜色。有可能吗?事先非常感谢;)

获得这种效果的简单方法是:

在布局上创建一个空的“面板”。例如:

<?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>

我以前没有在flash中使用过此类代码,因此您可能需要相应地调整持续时间。

在动画结束时添加View.VISIBLE而不是View.GONE

fade.setAnimationListener(new AnimationListener() {
...
@Override
public void onAnimationEnd(Animation anim) {
    pnlFlash.setVisibility(View.VISIBLE);
}
...
});
pnlFlash.startAnimation(fade); 

这是Kotlin的一个版本,因为您需要自己实现动画侦听器

private fun pictureTakenAnimation() {
    val listener = AnimationListener(pnlFlash)
    pnlFlash.visibility = View.VISIBLE

    val fade = AlphaAnimation(1f, 0f);
    fade.setDuration(500);
    fade.setAnimationListener(listener)
    pnlFlash.startAnimation(fade);
}

inner class AnimationListener(val v : View) : Animation.AnimationListener {
    override fun onAnimationStart(p0: Animation?) {
        v.visibility = View.VISIBLE
    }

    override fun onAnimationEnd(p0: Animation?) {
        v.visibility = View.GONE
    }

    override fun onAnimationRepeat(p0: Animation?) {

    }
}

我试图创建一个TransitionDrawable,我在这里寻找动画的一部分:我不知道如何在英文网站上搜索,因为我寻找的是“flash secreen”,我只找到了有关flash和Android的东西。
private fun pictureTakenAnimation() {
    val listener = AnimationListener(pnlFlash)
    pnlFlash.visibility = View.VISIBLE

    val fade = AlphaAnimation(1f, 0f);
    fade.setDuration(500);
    fade.setAnimationListener(listener)
    pnlFlash.startAnimation(fade);
}

inner class AnimationListener(val v : View) : Animation.AnimationListener {
    override fun onAnimationStart(p0: Animation?) {
        v.visibility = View.VISIBLE
    }

    override fun onAnimationEnd(p0: Animation?) {
        v.visibility = View.GONE
    }

    override fun onAnimationRepeat(p0: Animation?) {

    }
}