如何设置样式(小型和大型)按钮可编程方式?

Fer*_*and 4 android

如何设置样式(小型和大型)按钮可编程方式?

可能吗 ?

我可以将样式设置为来自xml资源的Button(如styte =?android:attr/buttonStyleSmall).但我不知道如何设置它的可编程方式.

提前致谢.

小智 10

你可以这样做:

Button button = new Button(this, null, android.R.attr.buttonStyleSmall);
Run Code Online (Sandbox Code Playgroud)