Thread
#compose
    e

    elye

    10 months ago
    Can I wrap Jetpack Compose inside an Android Custom View like below?
    class CustomView @JvmOverloads constructor(
            context: Context,
            attrs: AttributeSet? = null,
            defStyleAttr: Int = 0)
        : View(context, attrs, defStyleAttr) {
    
        // Some Jetpack Compose drawn item
    
    }
    I have also check in https://stackoverflow.com/q/69987040/3286489
    Dmitrii Smirnov

    Dmitrii Smirnov

    10 months ago
    You have to inherit from
    AbstractComposeView
    and override
    Content
    function
    e

    elye

    10 months ago
    @Chris Fillmore, thanks. The link only mentioned putting the Compose in Activity/Fragment/ViewHolder…. but not in a View. Maybe I miss something?
    Dmitrii Smirnov

    Dmitrii Smirnov

    10 months ago
    class CustomView @JvmOverloads constructor(
            context: Context,
            attrs: AttributeSet? = null,
            defStyleAttr: Int = 0)
        : AbstractComposeView(context, attrs, defStyleAttr) {
    
        @Composable
        override fun Content {
        //compose code here
        }
    
    }
    e

    elye

    10 months ago
    That looks promising… @Dmitrii Smirnov. Let me check that out 🙌 … Thank you so much!! 🙏