How to use own view in layout?

后端 未结 2 1527
礼貌的吻别
礼貌的吻别 2021-01-05 07:38

I created a class like this

public final class MyView extends View {

    public MyView(Context context, AttributeSet attrs) {
        super(context, attrs);         


        
相关标签:
2条回答
  • 2021-01-05 08:03

    You should write it like:

    <view class="com.hitziger.barcode.MyView"...
    
    0 讨论(0)
  • 2021-01-05 08:04

    in the layout.xml, use:

    <View 
        android:class="com.hitziger.barcode.MyView"
        android:id="@+id/my_view"
    ...
    

    istead of:

    <com.hitziger.barcode.MyView
        android:id="@+id/my_view"
    
    0 讨论(0)
提交回复
热议问题