gregkorossy / Android-Support-Preference-V7-Fix

Android androidx.preference support library has some issues, this lib tries to fix them.
https://discord.gg/87NVsSK
Apache License 2.0
497 stars 46 forks source link

Custom font in preference-v7 #110

Closed tcqq closed 6 years ago

tcqq commented 6 years ago

Hi, how to add custom font?

gregkorossy commented 6 years ago

You can override the styles to include your own font family but it is pretty cumbersome and there's no other way around it.

tcqq commented 6 years ago

Override the styles is hard-coded form, If the font allows custom settings, how do?

gregkorossy commented 6 years ago

There's no other way because the default Preference class does not provide this option and the TextViews (among other View items) are inaccessible. The only way would be to override the Preference class and use custom methods for setting the font family but this would also require all of the other Preference dependent classes to be overridden which is just too much work for too little gain. Also, you'd face more problems as you go deeper because you cannot change the font of the AlertDialog used by e.g. the ListPreference. This is the same argument again as with the programmatically changeable colors.

tcqq commented 6 years ago
  1. Use "Spannable" to set the font
  2. Use Reflection to get "TextView"
gregkorossy commented 6 years ago

You can do the first without requiring any extra methods in this lib. The second one still requires overriding all of the Preference children.

tcqq commented 6 years ago

OK, I will try.