error: No resource identifier found for attribute ‘footerColor’ in package

本文介绍了解决Android XML布局中常见的错误提示,特别是当使用自定义控件时如何正确指定包路径,避免出现找不到属性资源标识符的问题。通过一个具体例子展示了如何在XML布局文件中正确配置自定义控件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

异常提示:

使用自定义控件,引用包名应该是AndroidManifest.xml中所定义的包路径,并非src下.java文件所指向的包,这个容易犯错!

否者Android studio 中的xml布局界面,运行后会提示以下错误:

error: No resource identifier found for attribute ‘footerColor’ in package

一般情况下,加上这一句就可以了,特殊情况下,再根据上边那种实现

xmlns:app="http://schemas.android.com/apk/res-auto"

参考xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:id="@+id/container"
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.lvche.app"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res/com.lvche.app"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:background="@color/white_pure"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom"
        android:orientation="vertical"
        tools:ignore="UselessParent">

        <RelativeLayout
            android:id="@+id/topbanner"
            android:layout_width="match_parent"
            android:layout_height="@dimen/height_top_bar"
            android:background="@color/banner_bgcolor"
            android:gravity="center_vertical">

            <TextView
                android:id="@+id/topbanner_showtext"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="我的收藏"
                android:textColor="#ffffff"
                android:textSize="23sp"/>

            <Button
                android:id="@+id/topbanner_setting"
                android:layout_width="60dp"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:background="@color/orange"
                android:onClick="save"
                android:textColor="#fff"
                android:textSize="18sp"
                android:visibility="gone"/>
        </RelativeLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:orientation="vertical"
            tools:ignore="InefficientWeight">


            <com.lvche.app.incubator.ui.componennt.tabbarview.ui.TitleIndicator
                android:id="@+id/pagerindicator"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:background="#ffffff"
                app:footerColor1="@color/tab_indicator_text_selected"
                app:footerLineHeight1="0dp"
                app:footerTriangleHeight1="3.0dp"
                app:textColor="@color/tab_indicator_text"
                app:textSizeNormal="@dimen/common_text_size_middle_2"
                app:textSizeSelected="@dimen/common_text_size_middle_2"
              />

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="1.0dp"
                android:background="#eeeeee">
            </RelativeLayout>

            <!-- Don't set background for ViewPager. It doesn't work because of page margin -->

            <com.lvche.app.incubator.ui.componennt.tabbarview.ui.ViewPagerCompat
                android:id="@+id/pager"
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:clickable="false"
                android:duplicateParentState="true"/>
        </LinearLayout>
    </LinearLayout>

</RelativeLayout>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值