0

我在我的应用程序中使用pixate-freestyle-android库。我想在 XML 布局中定义样式类。

在文档中,我发现以下内容:

// Setting a class for a Button
Pixate.setStyleClass(button, "myButton");

这相当于在 XML 布局中定义一个类。

<Button
    class="myButton"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/myButtonStr"
    android:textSize="16sp" />

如果我在代码中以编程方式定义它们 - 它可以工作。但是,如果我在 XML 布局中定义它们,如上所示,Android Studio 在这一行指示我“未知属性类”,但它不起作用:

<Button
    ...
    class="myButton"
    ... />

是否可以在 XML 布局中定义样式类?

4

2 回答 2

0

属性class="myButton"不能再在最新版本的库中设置,只能以编程方式设置。

于 2015-08-05T07:56:43.640 回答
0

把它xmlns:app="http://schemas.android.com/apk/res/com.pixate.freestyle"放在你的根布局中,以便访问库的类。

于 2015-07-22T11:20:26.747 回答