Material TextInputLayout styles are not working when run on real device app crashes

空扰寡人 提交于 2019-12-14 04:14:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!