I use this code to get the text size of title and subtitle of Toolbar
val toolbar = findViewById<Toolbar>(R.id.myToolbar)
val titleSize =
(toolbar.getChildAt(0) as AppCompatTextView).textSize / resources.displayMetrics.density
val subTitleSize =
(toolbar.getChildAt(1) as AppCompatTextView).textSize / resources.displayMetrics.density
// hard code position 0 for title and 1 for subTitle may not work in all case, depend in your case, you can use a suitable value
Log.i("TAG", "title size $titleSize")
Log.i("TAG", "sub title size $subTitleSize")
with my current theme Theme.MaterialComponents.DayNight.DarkActionBar with androidx.appcompat.widget.Toolbar. title size is 20 and subtitle is 16