2015-07-28 36 views
1

我使用Android工作室,我想使用API​​超过21 首先,降低材料的设计特点我看这些问题:使用材料设计,前5个Android设备

how to use material design features in api lower than 21 in eclipse?

I want Material Design in Pre 5.0 device in eclipse

Android Design Support Library And Material Design Backwards Compatibility?

而且我也阅读这些:

https://developer.android.com/training/material/compatibility.html

https://developer.android.com/tools/support-library/features.html#v7-appcompat

而且我用这个教程创建一个兼容的材料设计项目:

http://www.androidhive.info/2015/04/android-getting-started-with-material-design/

我添加了这个库:com.android.support:appcompat-v7:21.0。 0和我使用像上一个链接的材质主题,但我无法看到我的android 4.2.2中的任何材质功能。正如我从谷歌开发人员了解到的,它使用兼容性来显示API 21中的材质特性,并且它仍然可以在android中低于21的材质特性下工作。 那么,如何使用低于21的android材质特性呢?

我gradle这个是这样的:

apply plugin: 'com.android.application' 

    android { 
    compileSdkVersion 21 
    buildToolsVersion "21.1.2" 

    defaultConfig { 
     applicationId "test.parsoa.com.newmaterial" 
     minSdkVersion 17 
     targetSdkVersion 21 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile "com.android.support:appcompat-v7:21.0.0" 
} 
+0

你'build.gradle'看起来像什么? – Nachi

回答

0

在第一次更新你的依赖,如:

dependencies { 
    compile "com.android.support:appcompat-v7:22.2.1" 
    compile 'com.android.support:design:22.2.1' // with this dependency you can use material design components pre api 21 
} 

只要看看在http://android-developers.blogspot.de/2015/05/android-design-support-library.html

+0

它给出这样的错误 >无法解析配置':app:_debugCompile'的所有依赖关系。 >找不到com.android.support:design:22.2.1。 我应该下载这个库吗? – Taher

+0

使用sdk管理器将您的sdk更新到最新版本,然后将您的compileSdkVersion更新为22 buildToolsVersion为“22.0.1”和targetSdkVersion 22 – eddykordo

+0

好的,我会尝试使用它们。 – Taher