首页 > Windows开发 > 详细

Attribute xx is only used in API level xx and higher (current min is   xx)的解决方法

时间:2015-08-11 19:20:40      阅读:1174      评论:0      收藏:0      [点我收藏+]

错误:Attribute "" is only used in API level 21 and higher (current min is   10)

问题重现:

    

1、在xml布局中碰到这样的问题是由于  配置了最低兼容Api。

    例如在AndroidManifest中配置:

    <uses-sdk

        android:minSdkVersion="10"

        android:targetSdkVersion="21" />

2、兼容到Api 10 也就是2.3.3的系统。

3、此时在布局中使用了Api21的 属性 :android:transitionName="y"

    <RelativeLayout

            android:id="@+id/titleLayout"

            android:transitionName="y"

            android:layout_width="match_parent"

            android:layout_height="45dp"

            android:background="@color/redColor" >

4、就会警告:Attribute "transitionName" is only used in API level 21 and higher (current min is 

 10)

5、解决方法如下根据属性的版本新建一个values-xx,根据上述例子,我们需要新建一个values-v21的文件

在里面新建一个styles.xml

技术分享

6、在代码中引入该style

    

<RelativeLayout

            android:id="@+id/titleLayout"

            style="@style/transitionName"

            android:layout_width="match_parent"

            android:layout_height="45dp"            

            android:background="@color/redColor" >

大功告成,values-v21是对资源进行版本适配


Attribute xx is only used in API level xx and higher (current min is   xx)的解决方法

原文:http://3048821.blog.51cto.com/3038821/1683561

(1)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!