在Eclipse中进行Android项目开发,需要在布局文件中用到TabLayout时无法使用app

一个昵称而已T 2016-02-14 11:34:12
下面是我的源码,并且在libs中添加了android-support-design.jar包
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >

<android.support.design.widget.TabLayout
android:id="@+id/id_tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
app:tabGravity="fill"
app:tabIndicatorColor="@color/main_color"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/main_color"
app:tabTextColor="#000000" />

<android.support.v4.view.ViewPager
android:id="@+id/id_viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />

</LinearLayout>

总是会提示error: No resource identifier found for attribute 'tabGravity' in package 'com.example.festival_sms'

请问应该怎么解决?
...全文
1209 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
bullet521 2017-10-23
  • 打赏
  • 举报
回复
楼主还在吗?我就是在Android studio 上遇到了这个问题,你能不能简单说一下你的解决方法。
AndroidGuy 2016-12-05
  • 打赏
  • 举报
回复
你当大家傻呀,这都不知道,具体情况具体分析,你自己用用就知道了
引用 7 楼 baidu_15995581 的回复:
http://www.jianshu.com/p/ef7a7c89ee70 在这里看到的,注意 在使用有的控件的时候,会用到自定义属性,比如CheckBox,需要在xml的最外层添加命名空间,代码如下: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:materialdesign="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" > </RelativeLayout> 如果不添加命名空间会出现如下错误:unbound prefix unbound prefix意思是前缀未被约定,比如我们写android:text="Iloveu",就引用了android空间中的text属性 所以,如果再遇到unbound prefix的问题,请查看命名空间有没有定义完全,或者是某部分隶属的布局中所使用的命名空间是否被定义了。一般来说,在xml的最开始就应该把所有要用到的xmlns声明好. 文/jackLee(简书作者) 原文链接:http://www.jianshu.com/p/ef7a7c89ee70 著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
伊蕾娜你老婆 2016-11-23
  • 打赏
  • 举报
回复
http://www.jianshu.com/p/ef7a7c89ee70

在这里看到的,注意

在使用有的控件的时候,会用到自定义属性,比如CheckBox,需要在xml的最外层添加命名空间,代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
如果不添加命名空间会出现如下错误:unbound prefix
unbound prefix意思是前缀未被约定,比如我们写android:text="Iloveu",就引用了android空间中的text属性
所以,如果再遇到unbound prefix的问题,请查看命名空间有没有定义完全,或者是某部分隶属的布局中所使用的命名空间是否被定义了。一般来说,在xml的最开始就应该把所有要用到的xmlns声明好.

文/jackLee(简书作者)
原文链接:http://www.jianshu.com/p/ef7a7c89ee70
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
伊蕾娜你老婆 2016-11-23
  • 打赏
  • 举报
回复
llayout布局文件最外面一层ViewGroup加上这个 xmlns:materialdesign="http://schemas.android.com/apk/res-auto",我是这样解决的
乐活青年 2016-09-28
  • 打赏
  • 举报
回复
我想楼主一定只是在supprot下找到design的libs导入到你的eclipse项目了,没有把design目录下的res中的内容导入。这个光有jar包是不够的,还需要必须的资源文件。
孤独de猫 2016-02-26
  • 打赏
  • 举报
回复
直接用android studio,就没这些问题了。
  • 打赏
  • 举报
回复
应该是二楼的前辈说的原因,后来我用的Android studio,至于Eclipse的不知道怎么解决
yiheng-mother 2016-02-25
  • 打赏
  • 举报
回复
我也遇到了相同的问题,请问楼主解决了吗?
bdmh 2016-02-15
  • 打赏
  • 举报
回复
你在attrs文件里是否对自定义的组件,声明了这个属性呢

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧