我想在我的应用程序中使用 API 21 开始的新设计支持库。 我想使用 Theme.Material 风格,但它只适用于 Theme.AppCompat 风格。 当我使用 Theme.Material 时,android 返回此错误:
error inflating class android.support.design.widget.textinputlayout"
我该如何解决?
提前致谢
Ps:抱歉我的英语不好,我是法国人。
更新: 这是我的代码
样式.xml
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorAccent">@color/accent</item>
<item name="android:colorControlNormal">@color/control_normal</item>
<item name="android:textColorHint">@color/silver</item>
</style>
Activity .xml
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="username"
android:id="@+id/editText1" />
</android.support.design.widget.TextInputLayout>
构建.gradle
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':facebook')
compile('com.twitter.sdk.android:twitter:1.1.0@aar') {
transitive = true;
exclude module: 'gson'
}
compile 'com.google.android.gms:play-services-plus:7.5.0'
compile 'com.google.android.gms:play-services-identity:7.5.0'
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:support-v13:22.0.0'
compile 'com.android.support:cardview-v7:22.0.0'
compile 'com.soundcloud.android:android-crop:0.9.10@aar'
compile files('libs/volley.jar')
compile files('libs/gson-2.3.1.jar')
compile files('libs/httpclient-4.3.3.jar')
compile files('libs/httpclient-cache-4.3.3.jar')
compile files('libs/httpcore-4.3.2.jar')
compile files('libs/httpmime-4.3.3.jar')
compile files('libs/commons-lang3-3.3.2.jar')
compile files('libs/hellocharts-library-1.5.5.jar')
}
最佳答案
TextInputLayout 依赖于 AppCompat 中的资源/属性。您需要使用 AppCompat 基本主题。
AppCompat themes是 API 21+ 上基于 Material 的主题的父级。因此,您将使用 Material 主题。
关于带有 Theme.Material 的 Android 设计支持库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30711813/