Android получает ошибку при использовании 'app: errorEnabled = "true"' в TextInputLayout

В моем приложении у меня есть макет TextInputLayout. Когда я пишу строку app: errorEnabled = "true", я получаю эту ошибку

Unhandled Exception: Android.Views.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class android.support.design.widget.TextInputLayout

Перед добавлением этой строчки все работает нормально

Это код моего TextInputLayout

<android.support.design.widget.TextInputLayout
    android:id = "@+id/til_email"
    android:layout_width = "match_parent"
    android:layout_height = "0dp"
    android:layout_weight = "130"
    android:layout_marginLeft = "25dp"
    android:layout_marginRight = "25dp"
    android:theme = "@style/TextLabel"
    app:errorTextAppearance = "@style/MyErrorText"
    app:errorEnabled = "true">
  <EditText
      android:id = "@+id/input_email"
      android:layout_width = "match_parent"
      android:layout_height = "wrap_content"
      android:singleLine = "true"
      android:inputType = "textEmailAddress"
      android:drawableStart = "@mipmap/stroke"
      android:drawableLeft = "@mipmap/stroke"
      android:theme = "@style/TextLabel"
      android:backgroundTint = "#9fa7b3"
      android:hint = "@string/username" />
</android.support.design.widget.TextInputLayout>

Это мой код файла стиля

<!---Style for LoginPage edit texts-->
<style name = "TextLabel" parent = "TextAppearance.AppCompat">
<!-- Hint color and label color in FALSE state -->
<item name = "android:textColorHint">#353535</item>
<item name = "android:textSize">20sp</item>
<!-- Label color in TRUE state and bar color FALSE and TRUE State -->
<item name = "colorAccent">#353535</item>
<item name = "colorControlNormal">#353535</item>
<item name = "colorControlActivated">#55b9aa</item>
<item name = "colorControlHighlight">#353535</item>
</style>

<!--Error label text style-->
<style name = "MyErrorText" parent = "TextAppearance.AppCompat.Small">
<item name = "android:textColor">@color/Pink</item>
</style>

Также я использую

public class LoginActivity : AppCompatActivity

0
0
1 227
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Нет проблем с app:errorEnabled = "true" Удалите атрибут theme из <android.support.design.widget.TextInputLayout, поскольку вы устанавливаете его также в EditText

Ниже приводится полный код:

<android.support.design.widget.TextInputLayout
android:id = "@+id/til_email"
android:layout_width = "match_parent"
android:layout_height = "0dp"
android:layout_weight = "130"
android:layout_marginLeft = "25dp"
android:layout_marginRight = "25dp"
app:errorTextAppearance = "@style/MyErrorText"
app:errorEnabled = "true">
<EditText
  android:id = "@+id/input_email"
  android:layout_width = "match_parent"
  android:layout_height = "wrap_content"
  android:singleLine = "true"
  android:inputType = "textEmailAddress"
  android:drawableStart = "@mipmap/stroke"
  android:drawableLeft = "@mipmap/stroke"
  android:theme = "@style/TextLabel"
  android:backgroundTint = "#9fa7b3"
  android:hint = "@string/username" />
</android.support.design.widget.TextInputLayout>

Спасибо. Вот в чем проблема.

Konstantinos Evangelidis 01.05.2018 16:52

Другие вопросы по теме