Android – Architecture – How to commonize/ customize Android view for frequent use in entire application?

Create file including custom Views

import android.view.View

fun View.gone() {
    visibility = View.GONE
}

fun View.visible() {
    visibility = View.VISIBLE
}

fun View.isVisible(): Boolean = visibility == View.VISIBLE

Use custom View anywhere inside application

import sample.app.com.extension.gone
import sample.app.com.extension.visible

oneViewId?.gone()
oneViewId?.visible()

Be the first to comment

Leave a Reply

Your email address will not be published.


*