没有合适的资源?快使用搜索试试~ 我知道了~
首页android实现手机截屏并保存截图功能
android实现手机截屏并保存截图功能
1.5k 浏览量
更新于2023-05-26
评论
收藏 59KB PDF 举报
主要为大家详细介绍了android实现手机截屏并保存截图功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
资源详情
资源评论
资源推荐

android实现手机截屏并保存截图功能实现手机截屏并保存截图功能
主要为大家详细介绍了android实现手机截屏并保存截图功能,具有一定的参考价值,感兴趣的小伙伴们可以参
考一下
本文实例为大家分享了android实现手机截屏并保存截图功能的具体代码,供大家参考,具体内容如下
一、准备一张图片一、准备一张图片
拷贝screenshot_panel.9.png放在目录drawable-xhdpi下
二、二、activity_main.xml
代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<Button
android:id="@+id/main_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Shot"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
三、新建三、新建xml文件文件
<?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">
<ImageView android:id="@+id/global_screenshot_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@android:color/black"
android:visibility="gone" />
<ImageView android:id="@+id/global_screenshot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/screenshot_panel"
android:visibility="gone"
android:adjustViewBounds="true" />
<ImageView android:id="@+id/global_screenshot_flash"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@android:color/white"
android:visibility="gone" />
</FrameLayout>
四、在四、在dimens.xml添加一项添加一项
<dimen name="global_screenshot_bg_padding">20dp</dimen>
五、后台代码五、后台代码














安全验证
文档复制为VIP权益,开通VIP直接复制

评论0