且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

对于自定义视图(振动的TextView)配置属性

更新时间:2023-02-26 22:36:33

我最近面临的相同问题。以下是 attrs.xml

I recently faced the exact same problem. Here are my custom attribute declarations in attrs.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="NumberPicker">
        <attr name="rangeStart" format="integer|reference" />
        <attr name="rangeEnd" format="integer|reference" />
        <attr name="speed" format="integer|reference" />
        <attr name="current" format="integer|reference" />
        <attr name="android:orientation" />
    </declare-styleable>
</resources>

您可以重复使用Android的属性,但是你不能教他们建议不同的值。事实上,你甚至不能教日食表明你的自定义属性的定义(在后的这一天,至少,我希望在将来能看到该功能)。

You can reuse the android attributes but you can't teach them to suggest different values. In fact you can't even teach eclipse to suggest your custom attribute definitions (at least at this date of post, I would love to see that feature in future).

一切你想知道如何定义自定义属性是这样的问题: Declaring一个定制的Andr​​oid UI元素使用XML 。

Everything else you would want to know about defining custom attributes is in the question: Declaring a custom android UI element using XML.