简体   繁体   English

我可以在反应原生的本机Android实现中使用静态布局(本机UI)吗?

[英]can I use static layout (native UI) in react native's native android implementation?

I am writing a react native application and I want to use some of the static layouts (for Android) I have from my old application. 我正在编写一个react本机应用程序,我想使用我的旧应用程序中的一些静态布局(对于Android)。

I looked at https://facebook.github.io/react-native/docs/native-components-ios.html and wrote a few classes (MyViewManager.java and MyView.java). 我查看了https://facebook.github.io/react-native/docs/native-components-ios.html并编写了一些类(MyViewManager.java和MyView.java)。

I want to be able to use the static layouts I have for MyView.java. 我希望能够使用MyView.java的静态布局。

I went through the facebook's react native code on github. 我在github上浏览了facebook的反应本机代码。

I could not find an appropriate method like setContentView(R.layout.myview). 我找不到像setContentView(R.layout.myview)这样的合适方法。 I was wondering if anybody tried this and this will work. 我想知道是否有人试过这个,这将有效。

Can someone please help me with this problem? 有人可以帮我解决这个问题吗?

You can try out something like 你可以尝试类似的东西

The layout inflater will inflate given xml file and put it as a child of this(second argument in inflate), which is MyLayoutView. 布局inflater将给出给定的xml文件,并将其作为此子项(inflate中的第二个参数),即MyLayoutView。

See the definition of inflate and change arguments as per customization required. 根据需要定制,查看膨胀和更改参数的定义。

public class MyManyViewsManager extends ViewGroupManager<MyLayoutView> {

}

class MyLayoutView extends FrameLayout {

  init() {
        rootItem = (ViewGroup) LayoutInflater.from(getContext()).inflate(R.layout.xmlfilename, this, true);
  }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM