Skip to content

Instantly share code, notes, and snippets.

@pjonceski
pjonceski / MyTabLayout.kt
Last active November 15, 2021 12:31
Custom views at TabLayout with custom text style and indicator at selected tab
class MyTabLayout : TabLayout {
private val mTitles: MutableList<String> = arrayListOf()
private var mUnselectedTypeFace: Typeface? = null
constructor(context: Context?) : super(context) {
init(context, null)
}
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
init(context, attrs)
/**
* This class is FragmentPagerAdapter where all the fragments are in an array and you can access to them later.
* @property mFragments the list of fragments,
* @property NUMBER_OF_FRAGMENTS the total number of fragments that will be created. Change the value of this param accordingly.
*/
class MyFragmentPagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) {
companion object {
private val NUMBER_OF_FRAGMENTS = 2
}