Unfortunately, android:hint will always override android:contentDescription. You can create TextView which you will use only to set android:labelFor but from my experience TalkBack will then read both hint and labelFor.
The right way to add TextView which is only for labeling EditText for TalkBack :
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:text="@string/yourDescription"
android:labelFor="@+id/editText" />
<EditText android:id="@+id/editText"/>
So one of the solutions is that you can check to see if TalkBack is on and change hint programmatically. You can check if TalkBack is on with:
if(context.isScreenReaderOn){
...
}
And you create an inline function in Kotlin like :
fun Context.isScreenReaderOn():Boolean{
val am = getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager
if (am != null && am.isEnabled) {
val serviceInfoList =
am.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_SPOKEN)
if (!serviceInfoList.isEmpty())
return true
}
return false}