【发布时间】:2019-08-28 10:57:19
【问题描述】:
我正在使用 Material 组件,但很遗憾,我无法使用 MaterialTextView。我不知道我错过了什么。
在我的build.gradle 文件中:
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
在styles.xml中:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.MaterialComponents.Light" />
我这样定义我的 TextView:
<MaterialTextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Some text"
android:textStyle="bold" />
当我尝试启动应用程序时,我收到此错误:didn't find class android.view.MaterialTextView.
所以我尝试使用包名com.google.android.material 指定,但在自动完成结果中没有出现textview。
【问题讨论】:
标签: android textview material-design material-components-android material-components