尝试以编程方式创建MaterialButton: private val button = MaterialButton(context, null, R.style.Widget_MaterialComponents_Button) 但是当它尝试渲染时,我得到了以下错误: Failed to find '@attr/textAppearanceButton' in current theme.我试图传入使用我的应用程序主题的上下文,该<e
我想以编程的方式创建一个按钮,如这里的设计指南所定义的:,如下所示:在XML中,我可以这样做,使用以下布局xml:MaterialButton testSignIn = new MaterialButton( new ContextThemeWrapper( this, R.style.Widget_MaterialComponen
我正在尝试动态创建材料按钮。我已经添加了所有的依赖项和所有内容。如果我在XML文件中创建它,它可以很好地工作,但当我尝试动态创建它时,它会给出错误创建我尝试过的材质按钮: MaterialButtonmaterialButton = new MaterialButton= new LayoutParams(LayoutParams.WRAP_CONTENT, myLayout
我正在尝试扩展ConstraintLayout,以便与Kotlin中的复合组件一起使用。我发现的大多数示例都是,其中构造函数有3个参数。但是,有一个接受另一个参数defStyleRes。用于它的正确默认值是什么?我认为0工作,类似于defStyleAttr。下面是我认为最终代码应该是什么样子:context: Context,private val defStyleAttr: Int = 0,
privat