Вот пользовательская реализация класса для ответа Аднеала .
public class CustomTextInputLayout extends TextInputLayout {
public CustomTextInputLayout(Context context) {
super(context);
initFont(context);
}
public CustomTextInputLayout(Context context, AttributeSet attrs) {
super(context, attrs);
initFont(context);
}
private void initFont(Context context) {
final Typeface typeface = Typeface.createFromAsset(
context.getAssets(), "fonts/YOUR_CUSTOM_FONT.ttf");
EditText editText = getEditText();
if (editText != null) {
editText.setTypeface(typeface);
}
try {
// Retrieve the CollapsingTextHelper Field
final Field cthf = TextInputLayout.class.getDeclaredField("mCollapsingTextHelper");
cthf.setAccessible(true);
// Retrieve an instance of CollapsingTextHelper and its TextPaint
final Object cth = cthf.get(this);
final Field tpf = cth.getClass().getDeclaredField("mTextPaint");
tpf.setAccessible(true);
// Apply your Typeface to the CollapsingTextHelper TextPaint
((TextPaint) tpf.get(cth)).setTypeface(typeface);
} catch (Exception ignored) {
// Nothing to do
}
}
}
В ваших XML-файлах теперь вам нужно использовать CustomTextInputLayout
вместо TextInputLayout
, и это будет работать из коробки.
Спасибо Adneal за ответ.
Вы уверены, что для свойства X_WIN_SERVICE_NAME задано правильное значение при удалении. Используйте файл подробного журнала, чтобы убедиться, что поиск устанавливает значение правильно. Все выглядит нормально (хотя я не знаю, почему вы помещаете все в файлы Include, а не просто используете фрагменты).