问题描述
react-native动态创建Android View 无效果,我想在react-native里面直接点击函数进行创建,也就是通过module中的方法创建View
问题出现的环境背景及自己尝试过哪些方法
无论怎么样就是不显示,初始化的就没有问题
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
初始化不存在问题
初始化:
relativeLayout = new LinearLayout(mContext);
relativeLayout.setBackgroundColor(Color.parseColor(("#fff000")));
relativeLayout.setMinimumHeight(MATCH_PARENT);
relativeLayout.setMinimumWidth(MATCH_PARENT);
TextView textView = new TextView(mContext);
textView.setText("222222");
textView.setBackgroundColor(Color.parseColor("#666666"));
relativeLayout.addView(textView);
但是当点击调用的时候就不会出现
js调用方法:
public void startPush() {
TextView textView1 = new TextView(mContext);
textView1.setText("55555");
textView1.setBackgroundColor(Color.parseColor("#666666"));
relativeLayout.addView(textView1);
}
你期待的结果是什么?实际看到的错误信息又是什么?
我就想知道怎么了,应该怎么解决呢 = =
重写requesLayout();onLayout设置宽高