帖子
帖子
用户
博客
课程
显示全部楼层
38
帖子
0
勋章
784
Y币

[插件开发] Android无法刷新

[复制链接]
发表于 2021-11-19 11:22:32
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)mLocalView.getLayoutParams();
            params.width = w;
            params.height = h;
            params.setMargins(x, y, 0, 0);

            mLocalView.setLayoutParams(params);

直接修改参数为大小一半,会修改父亲窗口的大小,自己的窗口也会变回设置值的一半;但是先remove,然后再insert,就是可以的,这种重置大小要怎么解决

0
帖子
1
勋章
2504
Y币
你可以看看
public void jsmethod_configPlayerView(UZModuleContext uzModuleContext) {
        JSONObject rect = uzModuleContext.optJSONObject("rect");
        if (null != rect) {
            x = rect.optInt("x");
            y = rect.optInt("y");
            w = rect.optInt("w");
            h = rect.optInt("h");
            LogUtil.logd("[configPlayerView]" + "h== " + h + "; w== " + w);
        }
        if (null == mplayerView) {
            mplayerView = new TXCloudVideoView(context());
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                mplayerView.setBackgroundColor(Color.parseColor("#000000"));
            }
        }
        RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(w, h);
        rlp.leftMargin = x;
        rlp.topMargin = y;
        fixedOn = uzModuleContext.optString("fixedOn");
        //fixed参数标识UI模块是否跟随网页滚动
        fixed = uzModuleContext.optBoolean("fixed", true);
        insertViewToCurWindow(mplayerView, rlp, fixedOn, fixed);
    }

    public void jsmethod_resizePlayerView(UZModuleContext uzModuleContext) {
        JSONObject rect = uzModuleContext.optJSONObject("rect");
        if (null != rect) {
            x = rect.optInt("x");
            y = rect.optInt("y");
            w = rect.optInt("w");
            h = rect.optInt("h");
            LogUtil.logd("[configPlayerView]" + "h== " + h + "; w== " + w);
            RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(w, h);
            rlp.leftMargin = x;
            rlp.topMargin = y;
            insertViewToCurWindow(mplayerView, rlp, fixedOn, fixed);
        }
    }
38
帖子
0
勋章
784
Y币
重复inserViewToCutWindow会报错
2021-11-19 12:12:36.886 8633-8633/io.dcloud.android.tencenttrtccalling E/AndroidRuntime: FATAL EXCEPTION: main
    Process: io.dcloud.android.tencenttrtccalling, PID: 8633
    java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
        at android.view.ViewGroup.addViewInner(ViewGroup.java:5361)
        at android.view.ViewGroup.addView(ViewGroup.java:5190)
        at android.view.ViewGroup.addView(ViewGroup.java:5130)
        at android.view.ViewGroup.addView(ViewGroup.java:5103)
        at com.uzmap.pkg.uzcore.y.a(Unknown Source:36)
        at com.uzmap.pkg.uzcore.h.f.a(Unknown Source:14)
        at com.uzmap.pkg.uzcore.uzmodule.UZModule$2.run(Unknown Source:23)
        at android.os.Handler.handleCallback(Handler.java:900)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:219)
        at android.app.ActivityThread.main(ActivityThread.java:8668)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
2021-11-19 12:12:36.910 8633-8633/io.dcloud.android.tencenttrtccalling E/app3c: sorry, we have catch a crash log in VOG-AL00|10
    java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
        at android.view.ViewGroup.addViewInner(ViewGroup.java:5361)
        at android.view.ViewGroup.addView(ViewGroup.java:5190)
        at android.view.ViewGroup.addView(ViewGroup.java:5130)
        at android.view.ViewGroup.addView(ViewGroup.java:5103)
        at com.uzmap.pkg.uzcore.y.a(Unknown Source:36)
        at com.uzmap.pkg.uzcore.h.f.a(Unknown Source:14)
        at com.uzmap.pkg.uzcore.uzmodule.UZModule$2.run(Unknown Source:23)
        at android.os.Handler.handleCallback(Handler.java:900)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:219)
        at android.app.ActivityThread.main(ActivityThread.java:8668)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
JP1688 · 2021-11-19 11:41你可以看看
public void jsmethod_configPlayerView(UZModuleContext uzModuleContext) {
        JSONObject rect = uzModuleContext.optJSONObject("rect");
0
帖子
1
勋章
2504
Y币
view设置全局的
您需要登录后才可以回帖 登录

本版积分规则