在布局文件中引用自定义控件,需要写类的完整路径。
 
例如:
 
 
 
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">
    <com.newsapp.view.MyImageView
        android:id="@+id/item_img_icon"
        android:layout_width="68dp"
        android:layout_height="68dp"
        android:layout_gravity="center"
        android:layout_marginEnd="10dp"
        android:scaleType="fitXY"
        android:src="@mipmap/ic_launcher" />
</LinearLayout> 
 
 
 
 
 
                
        
    
                    转载请注明原文地址: https://ju.6miu.com/read-586.html