什么是AttributeSet中,我该如何使用呢?我该、如何使用、AttributeSet

2023-09-06 01:30:11 作者:浅夏、旧时光

什么是属性集中的在Android的?

What is AttributeSet in Android?

我如何使用它为我的自定义视图?

How can i use it for my custom view?

推荐答案

AttributeSet中的是一组在XML资源文件中指定的属性。你不应该在你的自定义视图做什么特别的。该视图(上下文的背景下,ATTRS的AttributeSet)被调用来初始化从布局文件的视图。就在这个构造函数添加到您的自定义视图。退房的Custom查看比如在SDK中看到它。

AttributeSet is the set of properties specified in an xml resource file. You shouldn't have to do anything special in your custom view. The View(Context context, AttributeSet attrs) gets called to initialize a view from a layout file. Just add this constructor to your custom view. Check out the Custom View example in the SDK to see it used.

 
精彩推荐
图片推荐