与Theme.Material Android的设计支持库 [英] Android design support library with Theme.Material

本文介绍了与Theme.Material Android的设计支持库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用新的设计支持库在我的应用程序的API 21起。 我想用Theme.Material风格,但它的工作只与Theme.AppCompat风格。 当我使用Theme.Material,Android的这个错误:

  

错误充气类android.support.design.widget.textinputlayout

我怎样才能解决这个问题?

感谢你在前进

PS:对不起,我英文不好,我是法国人。

更新: 这是我的code

styles.xml

 <样式名称=AppTheme父=机器人:Theme.Material.Light.DarkActionBar>
    <项目名称=机器人:colorPrimary> @色/初级< /项目>
    <项目名称=机器人:colorPrimaryDark> @色/ primary_dark< /项目>
    <项目名称=机器人:colorAccent> @颜色/重音和LT; /项目>
    <项目名称=机器人:colorControlNormal> @色/ control_normal< /项目>
    <项目名称=机器人:textColorHint> @色/银< /项目>
< /风格>
 

activity.xml

 < android.support.design.widget.TextInputLayout
    机器人:layout_width =match_parent
    机器人:layout_height =WRAP_CONTENT>

    <的EditText
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        机器人:提示=用户名
        机器人:ID =@ + ID / editText1/>

< /android.support.design.widget.TextInputLayout>
 

build.gradle

 相关性{
//编译文件树(导演:库,包括:['的* .jar'])

编制项目(:Facebook的)
编译(com.twitter.sdk.android:twitter:1.1.0@aar'){
    传递= TRUE;
    排除模块:GSON
}

编译com.google.android.gms:玩-服务加:7.5.0
编译com.google.android.gms:播放服务身份:7.5.0
编译com.android.support:design:22.2.0
编译com.android.support:support-v13:22.0.0
编译com.android.support:cardview-v7:22.0.0
编译com.soundcloud.android:android-crop:0.9.10@aar

编译文件(库/ volley.jar)
编译文件(库/ GSON-2.3.1.jar)
编译文件(库/ HttpClient的-4.3.3.jar)
编译文件(库/ HttpClient的缓存-4.3.3.jar)
编译文件(库/的HttpCore-4.3.2.jar)
编译文件(库/ httpmime-4.3.3.jar)
编译文件(库/公地lang3-3.3.2.jar)
编译文件(库/ hellocharts库-1.5.5.jar)
}
 

解决方案

TextInputLayout依赖于资源/属性在AppCompat。您需要使用一个AppCompat基本主题。

的<一个href="https://github.com/android/platform_frameworks_support/blob/master/v7/appcompat/res/values-v21/themes_base.xml"相对=nofollow> AppCompat主题是的材料基础上的主题API父21+。所以,你将使用材料的主题。

I would like to use the new design support library in my application beginning with the API 21. I want to use Theme.Material style but it's work only with Theme.AppCompat style. When I use Theme.Material, android return this error:

error inflating class android.support.design.widget.textinputlayout"

How can I resolve it ?

Thank you in advance

Ps: Sorry for my bad english, i'm french.

UPDATE: Here is my code

styles.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>

build.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 relies on resources/attributes in AppCompat. You need to use an AppCompat base theme.

The AppCompat themes are a parent of the Material based themes on API 21+. So, you will be using the Material theme.

这篇关于与Theme.Material Android的设计支持库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆