【问题标题】:pixate-freestyle-android define style class in XML layoutpixate-freestyle-android 在 XML 布局中定义样式类
【发布时间】:2015-08-05 15:56:43
【问题描述】:

我在我的应用程序中使用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 在这一行指示我“Unknown attribute class”并且它不起作用:

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

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

【问题讨论】:

    标签: android pixate


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-01-25
        • 1970-01-01
        • 1970-01-01
        • 2011-04-21
        • 2023-03-14
        相关资源
        最近更新 更多