為什么setBackgroundColor()沒用,反而XML里的background可以
package?com.example.lenovo.viewbutton; import?android.content.Context; import?android.content.res.TypedArray; import?android.util.AttributeSet; import?android.view.View; /** ?*?Created?by?lenovo?on?2018/10/31. ?*/ public?class?NewButton?extends?View { ????public?NewButton(Context?context,?AttributeSet?attr) ????{ ????????super(context,?attr); ????????setBackgroundColor(0x44ff0000); ????} }
2020-03-07
因為XML中的顏色給setBackgroundColor()的顏色覆蓋了。