给现有视图添加自定义属性

huangapple go评论78阅读模式
英文:

Add Custom Attributes to Existing View

问题

我使用AndroidPlot已有一段时间,并发现有几个设置无法通过xml设置。现在在尝试使用BindingAdapter时,我创建了一些方法来扩展仅以编程方式提供的自定义现有属性。现在我的问题是,我必须将某些内容绑定到属性以使其生效。

因此,我有两个问题:

  1. 是否可以像使用BindingAdapters将xml属性添加到视图中一样做类似的操作?
  2. 或者是否可以强制 Android 在 OneTimeBinding 时使用 BindingAdapter?

谢谢。

英文:

I am using AndroidPlot since a while and found out that their are serveral settings, that cannot be set using xml.
Now during playing around with BindingAdapter, I created some Methodes to extend existing attributes with custom which are only provided Programmically.
Now my problem is that I have to bind something to the attributes in order to take effect.

So I have two questions:

  1. Is it possible to add xml-Attributes, using something simular
    like BindingAdapters to Views.
  2. Or is it possible to force android to use the BindingAdapter for OneTimeBinding?

Thanks

答案1

得分: 0

我使用了ViewModel来解决这个图表问题,这样我可以使用TDD来额外检查状态,并且可以使用BindingAdapter来添加一些XML属性。

英文:

I solved it using a ViewModel for the Diagramm, so I can check the States additionally using TDD and can use the BindingAdapter to add some xml Attributes.

huangapple
  • 本文由 发表于 2020年4月4日 05:25:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/61020623.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定