Gradle工具会自动识别,所以不用指定包名
把
xmlns:xx="http://schemas.android.com/apk/res/com.xxx"
换成
例如下面的其中 ratingbar就是自定义属性,
<com.abct.tljr.ui.widget.RatingBar android:id="@+id/layout_main_recommend_item_star_bar" android:layout_width="wrap_content" android:layout_height="wrap_content" ratingbar:clickable="false" ratingbar:starCount="5" android:layout_below="@+id/tv_level" android:layout_marginLeft="15dp" android:layout_alignLeft="@id/tv_name" ratingbar:starEmpty="@drawable/img_xingxing3" ratingbar:starFill="@drawable/img_xingxing1" ratingbar:starHalf="@drawable/img_xingxing2" ratingbar:starImageSize="25dp" />
所以要在自定义控件所在的xml中的根布局中做出如下的属性设置
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ratingbar="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="vertical">