angebagui / medium-textview

Medium android application displays content with text, image, video etc in post detail. It can be a pain to do it with content came from CMS. So i decided to design that View to display the content quickly
496 stars 63 forks source link

how to change the text size? #4

Open iloster opened 7 years ago

gorrotowi commented 7 years ago
import android.view.ViewGroup
import android.widget.TextView
import io.github.angebagui.mediumtextview.ParagraphView
import mx.jetty.jetty.jettyelements.FontManager

/**
 * @author Gorro
 * @since 06/09/17.
 */

fun ViewGroup.setFont() {
    (0..this.childCount).map {
        val view = this.getChildAt(it)
        if (view is ParagraphView) {
            (0..view.childCount).map { index ->
                val txtV = view.getChildAt(index)
                if (txtV is TextView) {
                    if (it == 0) {
                        FontManager(txtV.context).initStyle(txtV, 1)
                        txtV.textSize = 24f
                    } else {
                        FontManager(txtV.context).setTypeFace(txtV)
                    }
                }
            }
        }
    }
}

I wrote this Kotlin function to change the font Of course

FontManager(txtV.context).initStyle(txtV, 1)

it's a function to set te TypeFont :)