Button和TextView

我们查看源码,Button实际上就是继承TextView,并没有实现什么方法,也没有做特殊处理。

区别在于:
TextView 用的是 textViewStyle
public TextView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, com.android.internal.R.attr.textViewStyle);
}

Button用的是 buttonStyle
public Button(Context context, AttributeSet attrs) {
this(context, attrs, com.android.internal.R.attr.buttonStyle);
}

猜你喜欢

转载自blog.csdn.net/qq_18581651/article/details/54948081