Post Rendering

Custom Post Rendering

UIKit provides default renderers for the core data types, text, image, and file. For custom post rendering, a map of data type and renderer can be registered and UIKit will refer to this map while rendering post component.


// To provide a custom renderer, implement an AmityPostRenderer
val customViewHolder = object : AmityPostRenderer {

    // Specify the dataType to be rendered by this renderer
    override fun getDataType(): String = "myapp.customtype"

    // Provide a layout of your viewHolder
    override fun getLayoutId(): Int = R.layout.custom_post

    // Provide a viewHolder that is subclassed from AmityPostContentViewHolder
    override fun createViewHolder(
        view: View
    ): AmityPostContentViewHolder {
        return MyCustomViewHolder(view)

    // Choose whether to have a post header
    override fun enableHeader(): Boolean {
        return true 

    // Choose whether to have a post footer 
    override fun enableFooter(): Boolean {
        return false
 // Register the custom renderer    

Last updated