Я попытался 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" />
...
Ожидаемый
Фактический