且构网

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

对于Android的TextView的自定义属性

更新时间:2022-11-19 13:44:32

据我知道你有2个选择:

As I know you have 2 options:


  • 创建一个扩展的TextView 并具有构造函数的AttributeSet 您自己的看法。然后,你可以在这个构造器自定义属性。检查本教程:创建一个视图类

  • 实施自己的 LayoutInfalter.Factory 在那里你处理自定义属性。

  • Create your own view that extends TextView and has constructor that takes AttributeSet. Then you can get custom property in this constructor. Check this tutorial: Creating a View Class.
  • Implement own LayoutInfalter.Factory where you handle custom attributes.

***检查一下这个问题:如何读取Android的自定义属性这几乎是一样的。

Better check this question: How to read custom attributes in Android it's almost the same.