image - 将布局保存到图库
问题描述
我正在写一个笔记应用程序,想将整个布局保存到一个图像中,并将其保存在我的画廊中或与其他应用程序共享。我不知道从哪里开始,所以使用了库Layout_to_image。但我有一个错误在线:bitmap=layout_to_image.convert_layout(); 这是错误:原因:java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法“int android.graphics.Bitmap.getWidth()”
这是我的代码
AppCompatTextView txt_screen;
Bundle bundle;
Layout_to_Image layout_to_image;
Bitmap bitmap;
RelativeLayout theWholeLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_screen_note);
bundle = getIntent().getExtras();
String description = bundle.getString("description");
txt_screen = findViewById(R.id.txt_screen);
theWholeLayout = findViewById(R.id.theWholeLayout);
txt_screen.setText(description);
layout_to_image = new Layout_to_Image(ScreenNoteActivity.this, theWholeLayout);
bitmap = layout_to_image.convert_layout();
任何帮助表示赞赏。
解决方案
推荐阅读
- typescript - 打字稿对象文字
- java - 在 build.gradle 中添加为依赖项时,让依赖项 jar 自动添加到 STS 项目
- python - 将自定义视觉输出转换为 TensorFlow 对象检测 API 可视化?
- python - Flask WTForms 自定义验证器不起作用
- date - 用日期和月份格式化日期
- python - 为什么我的代码不起作用?我是在 Python3 上使用 pandas 的新手
- reactjs - 实现 useFetch 反应钩子在提交函数中工作
- c# - WPF 使用 DataType 属性切换多个控件模板失败
- c - gtk3 - 使用 GSimpleAction 时保留快捷方式
- python - 玩家运动的python类问题