温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-06-14 02:50:06 来源:网络 阅读:1575 作者:378205481 栏目:移动开发

错误: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

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

6、在代码中引入该style

    

<RelativeLayout

            android:id="@+id/titleLayout"

           

            android:layout_width="match_parent"

            android:layout_height="45dp"            

            android:background="@color/redColor" >

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


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI