android - Android Studio 3.1.4 设计预览不渲染材料设计元素
问题描述
我正在使用 Android Studio 3.1.4。为了使用最新的材料设计库,我将编译和目标 SDK 版本更新为 28。现在,我在基本线性布局中使用一些 TextInputLayouts 和 TextInputEditTexts,并且设计预览无法正确呈现它们。它也不会渲染任何正确跟随它的元素。我在设计预览中收到以下错误:
java.lang.IllegalArgumentException:restoreToCount 中的下溢 - 在 android.support.design.widget.CutoutDrawable.postDraw(CutoutDrawable.java:113) 在 android.graphics.Canvas.restoreToCount(Canvas.java:604) 在 android .support.design.widget.CutoutDrawable.draw(CutoutDrawable.java:87) 在 android.support.design.widget.TextInputLayout.draw(TextInputLayout.java:1575)
这是预览的实际外观 - 对设计没有特别帮助:
我一直在寻找解决此问题的方法,但似乎找不到任何对当前版本的 Android Studio 或 SDK 28 有用的东西。这是应用程序 build.gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.the.appname.here"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support:exifinterface:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-v4:28.0.0-rc01'
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.android.support:recyclerview-v7:28.0.0-rc01'
implementation 'com.android.support:cardview-v7:28.0.0-rc01'
implementation 'com.android.support:design:28.0.0-rc01'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation ('com.twitter.sdk.android:twitter:3.3.0@aar') {
transitive = true
}
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}
apply plugin: 'com.google.gms.google-services'`
候选发布库之一是否可能存在问题?
解决方案
为了完成这项工作,我改变了:
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
( rc01 )
到
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
( alpha1 )
我在网上看到了这个,根据我的测试它正在工作,唯一的缺点是你必须在每个项目上进行这个更改。
推荐阅读
- python - numpy - 为什么 Z[(0,2)] 可以在某些情况下查看并在其他情况下复制?
- java - 如何高效压缩三色图片
- python - 使用curve_fit进行多元高斯拟合的问题
- python - 如何拆分具有多个定界符的字符串,但每个定界符仅一次?Python
- reactjs - React-Bootstrap 轮播滑块:如何检测显示中的当前幻灯片
- mongodb - 使用 mongoimport 时,可以指定 _id 应该是 UUID 吗?
- javascript - 如何使用字典在 JavaScript 返回值中实现回调
- c++ - 参考偏移量中看似无关的规范
- c# - 如何以管理员身份使用windows服务启动软件?
- html - 里面的引号
显示为“”或类似字符的元素