简体   繁体   English

Android屏幕截图

[英]Android screen shot

I wanted to take screen shots from the android screen with a floating button. 我想使用浮动按钮从android屏幕上拍摄屏幕快照。 I made the floating button and it takes screen shots and everything works well but there are two questions 1. How can my app take screenshot in a way that the floating button gets hidden then appears after the screen shot has been taken in order not to bother the user 2. When you press the volume down and power key to take screenshot, it has a great animation. 我制作了浮动按钮,它拍摄了屏幕快照,并且一切正常,但是有两个问题:1.我的应用程序如何以隐藏浮动按钮的方式进行屏幕截图,然后在拍摄屏幕快照后出现,以免打扰用户2.当您按下音量调低和电源键以截屏时,它具有出色的动画效果。 How can i add that animation? 如何添加该动画?

Add it in your java file 将其添加到您的Java文件中

View b = findViewById(R.id.button); 
b.setVisibility(View.GONE);

Get your button's view, and just before taking the screenshot, hide it and unhide it after you are done taking the screenshot in the floating button's onClick method. 获取按钮的视图,在截屏之前,在浮动按钮的onClick方法中截屏之后,将其隐藏并取消隐藏。

findViewById(R.id.floating_button).setVisibility(View.INVISIBLE);
// Take screenshot here
findViewById(R.id.floating_button).setVisibility(View.VISIBLE);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM