作为父级的 CustomTextView 和作为父级的 Textview 之间的区别

Difference between CustomTextView as Parent and Textview as Parent

我创建了 CustomTextview 如下

public class CustomTextView extends AppCompatTextView {
        public CustomTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
       // im changing font family here .ttf files
    }
}

.

<com.android.app.CustomTextView
android:id="@+id/view”
/>

有什么区别

这个

CustomTextView textView = findViewbyId(R.id.view);

还有这个

TextView textView = findViewbyId(R.id.view);

当我把这个 TextView textView = findViewbyId(R.id.view); IDE 运行时没有抛出错误。为什么?谢谢!

现实生活比较:

When you learn to drive a manual transmission car, you can drive almost any manual transmission car. Imagine how bad it would be if you had to learn to drive every different model of car you encounter.

来源(+)