Android打印图片
来源:互联网 发布:ubuntu如何查看版本号 编辑:程序博客网 时间:2024/06/05 07:32
抄自安卓官方开发文档,翻墙不易,英文日后再翻译吧,https://developer.android.com/training/printing/photos.html#image
Printing Photos
Taking and sharing photos is one of the most popular uses for mobile devices. If your application takes photos, displays them, or allows users to share images, you should consider enabling printing of those images in your application. The Android Support Library provides a convenient function for enabling image printing using a minimal amount of code and simple set of print layout options.
This lesson shows you how to print an image using the v4 support library PrintHelper
class.
Print an Image
The Android Support Library PrintHelper
class provides a simple way to print of images. The class has a single layout option, setScaleMode()
, which allows you to print with one of two options:
SCALE_MODE_FIT
- This option sizes the image so that the whole image is shown within the printable area of the page.SCALE_MODE_FILL
- This option scales the image so that it fills the entire printable area of the page. Choosing this setting means that some portion of the top and bottom, or left and right edges of the image is not printed. This option is the default value if you do not set a scale mode.
Both scaling options for setScaleMode()
keep the existing aspect ratio of the image intact. The following code example shows how to create an instance of the PrintHelper
class, set the scaling option, and start the printing process:
private void doPhotoPrint() { PrintHelper photoPrinter = new PrintHelper(getActivity()); photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.droids); photoPrinter.printBitmap("droids.jpg - test print", bitmap);}
This method can be called as the action for a menu item. Note that menu items for actions that are not always supported (such as printing) should be placed in the overflow menu. For more information, see the Action Bar design guide.
After the printBitmap()
method is called, no further action from your application is required. The Android print user interface appears, allowing the user to select a printer and printing options. The user can then print the image or cancel the action. If the user chooses to print the image, a print job is created and a printing notification appears in the system bar.
If you want to include additional content in your printouts beyond just an image, you must construct a print document. For information on creating documents for printing, see the Printing an HTML Document or Printing a Custom Document lessons.
- Android打印图片
- 打印图片
- 图片打印
- Android 蓝牙打印小票与WiFi打印小票两种打印方式的实现(带有图片和二维码)
- 读取图片并打印图片
- android ESC/POS兼容指令集 蓝牙打印图片和图片叠加水印
- Bitmap图片打印
- C#打印图片
- C#打印图片
- C# 打印图片
- C#实现图片打印
- C#图片和打印
- 如何打印图片
- ESC指令打印图片
- java 打印图片
- 打印一张图片
- Java打印自定义图片
- MFC打印图片
- 欢迎使用CSDN-markdown编辑器
- Java实现数据库数据导出到Excel中并下载到浏览器本地
- 算法之交换排序
- 关于通频带,3dB带宽,三阶截点和1dB压缩点,截止频率,频率范围,带宽,特征频率(中心频率),截止频率和增益(db)
- 两款网络测速工具 Speedtest & Speedster
- Android打印图片
- Where is $HADOOP_HOME on CDH 5.X, Parcels
- JUnit 4 与 TestNG 对比
- linux磁盘配额 quota
- Dungeon Game解题报告
- android 开发 获取apk 信息和sha1值的项目
- Sendfile & Zero-copy
- java预防表单重复提交
- js中创建、添加、删除、移动、复制和查找(子)节点