View(Context context, AttributeSet attrs, int defStyle)
样式无效,怎么回事?? Button newButton = new Button(this, null, R.style.myButtonStyle);
newButton.setText("我是按钮");样式代码
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="myButtonStyle">
<item name="android:layout_width">200px</item>
<item name="android:layout_height">300px</item>
<item name="android:textColor">#ff0000</item>
<item name="android:textSize">20px</item>
</style>
</resources>
样式无效,怎么回事?? Button newButton = new Button(this, null, R.style.myButtonStyle);
newButton.setText("我是按钮");样式代码
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="myButtonStyle">
<item name="android:layout_width">200px</item>
<item name="android:layout_height">300px</item>
<item name="android:textColor">#ff0000</item>
<item name="android:textSize">20px</item>
</style>
</resources>
第三个参数用到样式了啊,
Since: API Level 1 Perform inflation from XML and apply a class-specific base style. This constructor of View allows subclasses to use their own base style when they are inflating. For example, a Button class's constructor would call this version of the super class constructor and supply R.attr.buttonStyle for defStyle; this allows the theme's button style to modify all of the base view attributes (in particular its background) as well as the Button class's attributes.
Button newButton = new Button(this, null, android.R.attr.buttonStyle);我想要实现的功能是改变自带Button类的原来样式,用我继承系统的样式啊