我正在使用 Kotlin 前端/Python 后端构建一个应用程序。我的 python 脚本在 getFilesDir() 目录 (/data/user/0/com.example.myproject/files/mygraph.png) 下创建一个 .png 文件。然后我想使用 kotlin 获取 .png 文件并将其显示在 imageview 上。
相信我必须使用位图,但我不熟悉它,所以非常感谢您的支持。
class Graph : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_graph)
val dir = "/data/user/0/com.example.myproject/files/mygraph.png"
//Bitmap function
}
}
Use BitmapFactory
解码文件路径
val imageView = ImageView(this)
imageView.setImageBitmap(BitmapFactory.decodeFile(filePath))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)