本文整理汇总了Java中android.support.v4.print.PrintHelper.setScaleMode方法的典型用法代码示例。如果您正苦于以下问题:Java PrintHelper.setScaleMode方法的具体用法?Java PrintHelper.setScaleMode怎么用?Java PrintHelper.setScaleMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.print.PrintHelper
的用法示例。
在下文中一共展示了PrintHelper.setScaleMode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printPhoto
import android.support.v4.print.PrintHelper; //导入方法依赖的package包/类
public void printPhoto() {
if (!(albumItem instanceof Photo)) {
Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show();
return;
}
PrintHelper photoPrinter = new PrintHelper(this);
photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
try {
photoPrinter.printBitmap(albumItem.getPath(),
albumItem.getUri(this));
} catch (FileNotFoundException e) {
Toast.makeText(this, "Error (FileNotFoundException)", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
示例2: printImage
import android.support.v4.print.PrintHelper; //导入方法依赖的package包/类
public void printImage()
{
if (PrintHelper.systemSupportsPrint())
{
// use Android Support Library's PrintHelper to print image
PrintHelper printHelper = new PrintHelper(getContext());
// fit image in page bounds and print the image
printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
printHelper.printBitmap("Doodlz Image", bitmap);
}
else
{
// display message indicating that system does not allow printing
Toast message = Toast.makeText(getContext(),
R.string.message_error_printing, Toast.LENGTH_SHORT);
message.setGravity(Gravity.CENTER, message.getXOffset() / 2,
message.getYOffset() / 2);
message.show();
}
}
示例3: print
import android.support.v4.print.PrintHelper; //导入方法依赖的package包/类
private void print() {
// Get the print manager.
PrintHelper printHelper = new PrintHelper(this);
// Set the desired scale mode.
printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
// Get the bitmap for the ImageView's drawable.
Bitmap bitmap = ((BitmapDrawable) mImageView.getDrawable()).getBitmap();
// Print the bitmap.
printHelper.printBitmap("Print Bitmap", bitmap);
}
示例4: printImage
import android.support.v4.print.PrintHelper; //导入方法依赖的package包/类
private void printImage(String fileName, Bitmap bitmap) {
if (PrintHelper.systemSupportsPrint()) {
PrintHelper printHelper = new PrintHelper(this);
printHelper.setColorMode(PrintHelper.COLOR_MODE_COLOR);
printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
printHelper.printBitmap(fileName, bitmap);
} else {
Toast.makeText(this, "この端末では印刷をサポートしていません", Toast.LENGTH_SHORT)
.show();
}
}
示例5: doPhotoPrint
import android.support.v4.print.PrintHelper; //导入方法依赖的package包/类
private void doPhotoPrint(Bitmap bitmap) {
PrintHelper photoPrinter = new PrintHelper(this);
photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
photoPrinter.printBitmap("Design print", bitmap);
}