I have 3 text views on the screen. The first is guaranteed to be the longest with the other two shorter than it. I am using autoSizeText in the layout (shown below) to set the font size for the first one. This works as expected.
android:maxLines="1"
app:autoSizeTextType="uniform"
app:autoSizeMinTextSize="10sp"
app:autoSizeMaxTextSize="200sp"
I want the other two text views to copy the first one's font size so all three have consistent sizing. The only way I have found to do this is to wait for the entire fragment/activity to be laid out and rendered, and then copy the value from the first one (shown below). This works but causes a momentary flicker as the second and third field are first drawn at a smaller size and then resized. I am also concerned that a device could theoretically be slow enough that my delayed post will trigger before everything is laid out and sized. This feels sloppy and I think there should be a better way of doing this, but I failed to find it.
handler.postDelayed(
{
if (firstButton != null) {
secondButton?.setTextSize(TypedValue.COMPLEX_UNIT_PX, firstButton.textSize)
thirdButton?.setTextSize(TypedValue.COMPLEX_UNIT_PX, firstButton.textSize)
}
}, 50)