<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/qrcodeContentLl"
android:background="#F0E68C"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="100dp"
android:text="二维码快照"
android:textSize="18sp"
android:textStyle="italic" />
<ImageView
android:id="@+id/qrcodeIv"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:scaleType="fitCenter" />
<!--<TextView-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_marginTop="800dp"-->
<!--android:text="ahahds"-->
<!--android:layout_gravity="center"/>-->
</LinearLayout>
private void inflateAndShowCaptureView() {
if (hideView == null) {
hideView = LayoutInflater.from(this).inflate(R.layout.layout_quick_capture, null);
qrcodeIv = (ImageView) hideView.findViewById(R.id.qrcodeIv);
hideView.setDrawingCacheEnabled(true);//设置控件允许绘制缓存
hideView.measure(View.MeasureSpec.makeMeasureSpec(mainLayoutLl.getWidth(), View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
hideView.layout(0, 0, hideView.getMeasuredWidth(), hideView.getMeasuredHeight());
} else {
hideView.destroyDrawingCache();//要得到新的视图,就得销毁之前的缓存
}
showCaptureView();
}
private void showCaptureView() {
String content = contentEt.getText().toString().trim();
if (content == null || content.length() == 0) {
return;
}
if (qrcodeIv.getWidth() == 0) {
return;
}
Bitmap qrcodeBitmap = ZXingUtils.createQRImage(content, qrcodeIv.getWidth(), qrcodeIv.getHeight());
qrcodeIv.setImageBitmap(qrcodeBitmap);//先将生成的二维码显示在加载的视图上
Bitmap bitmap = hideView.getDrawingCache(); // 获取视图的绘制缓存(快照)
if (bitmap != null) {
showIv.setImageBitmap(bitmap);
}
}
hideView.measure(View.MeasureSpec.makeMeasureSpec(mainLayoutLl.getWidth(), View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
hideView.layout(0, 0, hideView.getMeasuredWidth(), hideView.getMeasuredHeight());
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有