问题
I have the problem with material components style . When adding below style into TextInputLayout the app crashes but in android studio preview it shows.
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
Activity code---
<com.google.android.material.textfield.TextInputLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="ORDER`enter code here` NO"
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
>
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/orderNo"
android:layout_width="173dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:background="@null"
android:imeOptions="actionNext"
android:inputType="number"
android:padding="10dp"
/>
</com.google.android.material.textfield.TextInputLayout>
dependency-----
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.material:material:1.1.0-alpha10'
implementation 'com.vivekkaushik.datepicker:datePickerTimeline:0.0.3'
}
回答1:
Try to replace this dependency if your app theme is not Theme.MaterialComponents
implementation 'com.google.android.material:material:1.1.0-alpha10'
with this
implementation 'com.google.android.material:material:1.0.0'
来源:https://stackoverflow.com/questions/58234653/material-textinputlayout-styles-are-not-working-when-run-on-real-device-app-cras