All Downloads are FREE. Search and download functionalities are using the official Maven repository.

androidMain.tech.skot.view.extensions.TextViewExtensions.kt Maven / Gradle / Ivy

There is a newer version: 1.2.9
Show newest version
package tech.skot.view.extensions

import android.graphics.Paint
import android.widget.TextView

fun TextView.underline(state: Boolean = true) {
    paintFlags = if (state) {
        paintFlags or Paint.UNDERLINE_TEXT_FLAG
    } else paintFlags and Paint.UNDERLINE_TEXT_FLAG.inv()
}

fun TextView.strike(state: Boolean = true) {
    paintFlags = if (state) {
        paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
    } else paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
}

fun TextView.setTextOrGone(newText:CharSequence?) {
    text = newText
    setVisible(!text.isNullOrBlank())
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy