React native 如何访问本机UI组件中的style属性?

React native 如何访问本机UI组件中的style属性?,react-native,react-native-android,React Native,React Native Android,我正在为React native开发一个本机UI组件(这个问题涉及Android)。我用@ReactProp在android端获得了组件道具。当我试图以同样的方式阅读常规样式道具时,问题就出现了。它根本无法进入函数a中,a写道: @ReactProp(name = "style") public void setStyle(PickerView view, @Nullable ReadableMap style) { // never reaching here } 任何其他属性名称

我正在为React native开发一个本机UI组件(这个问题涉及Android)。我用@ReactProp在android端获得了组件道具。当我试图以同样的方式阅读常规样式道具时,问题就出现了。它根本无法进入函数a中,a写道:

@ReactProp(name = "style")
public void setStyle(PickerView view, @Nullable ReadableMap style) {
    // never reaching here 
}

任何其他属性名称似乎都有效。我想这是因为风格道具的处理方式不同。如何访问提供的样式道具

要访问Android中的
样式
道具,您可以使用
ReactPropGroup
如下:

@ReactPropGroup(names = {"height", "width", "zIndex", "right", "top"}, customType = "Style")
public void setStyle(PickverView view, int index, Integer style) {
  //
}}
然后,您可以使用
索引的值
来知道调用了
名称
中定义的属性