为什么这种可绘制的语言会以隐形的形式返回

afdcj2ne  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(175)

takedrawableofview函数的行为应该像是对约束视图上的所有内容进行“快照”。当我在调试时运行我的应用程序时,我注意到“finalimage”变量下的图像是“不可见的”(那里什么都没有),而我希望看到的是我的约束视图的图像和它当前的所有内容。

finalButton.setOnClickListener {
   val intent = Intent(this,MainActivity2::class.java)

     Log.d("SS","this function creates a drawable")
     //testing this screenshot function , code below creates a bitmap
    fun takeDrawableOfView(view: View, height: Int, width: Int): Bitmap {
        val myBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
        return myBitmap
    }

     //here we activate function
    val finalImage = takeDrawableOfView(findViewById<ConstraintLayout>(R.id.myConstraintView) , 1920 ,880)
     Log.d("SS","here we activated our function on the view")
     intent.putExtra("finalImage",finalImage)

Log.d("SS","put our new bitmap in intent extras")

     //take us to next page
   startActivity(intent)

我知道位图可能太大,无法通过intent传输,所以我计划将其存储在文件中,或者将位图转换为字符串。稍后我将在另一个活动的imageview中使用此位图,这就是我需要进行此传输的原因。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题