MaterialComponents> 1.0.0 возвращается к AppCompat - PullRequest
0 голосов
/ 07 ноября 2019

Я попытался MaterialComponents 1.0.0 в своем приложении, чтобы использовать выделенный дизайн текстового поля. Все было хорошо, но я также хотел использовать свойство startIconDrawable. Оказалось, что для этого мне нужно было обновить хотя бы до 1.1.0. Я сделал, но после обновления весь дизайн вернулся к стилю AppCompat.

Вот код

build.gradle (модуль приложения)

...
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.navigation:navigation-fragment:2.1.0'
    implementation 'androidx.navigation:navigation-ui:2.1.0'
    implementation 'com.google.android.material:material:1.2.0-alpha01'
}

РЕДАКТИРОВАТЬ: также пробовал 1.1.0-beta01.

styles.xml

<resources>
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:colorBackground">@color/colorPrimary</item>
    </style>
</resources>

фрагмент.xml

...
<com.google.android.material.textfield.TextInputLayout
        android:id="@+id/registerDate"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/date"nt"
        app:layout_constraintTop_toTopOf="parent"
        app:startIconDrawable="@drawable/outline_calendar_today_24">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/registerDateField"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="date" />
...

Ожидаемый

enter image description here

Фактический

enter image description here

1 Ответ

0 голосов
/ 09 ноября 2019

Я решил воссоздать проект с нуля, и теперь все в порядке.

Я отправляю этот ответ, потому что у меня были другие, казалось бы, не связанные проблемы, и несколько ответов на те, которые говорили, что очисткакеш в Android Studio их решает.

Я не пытался решить эту проблему с помощью очистки кеша, но он может работать.

...