本文介绍了在真实设备上运行的应用崩溃时,材料TextInputLayout样式不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对材料组件样式有疑问.将以下样式添加到TextInputLayout中时,应用程序崩溃,但在android studio预览中显示.
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"
活动代码---
<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>
依赖性-----
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'
}
推荐答案
如果您的应用主题不是Theme.MaterialComponents
Try to replace this dependency if your app theme is not Theme.MaterialComponents
implementation 'com.google.android.material:material:1.1.0-alpha10'
与此
implementation 'com.google.android.material:material:1.0.0'
这篇关于在真实设备上运行的应用崩溃时,材料TextInputLayout样式不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!