java 代码 添加控件 修改位置

只谈情不闲聊 提交于 2019-11-26 12:50:16
        Button button = new Button(this);
        FrameLayout frameLayout = getWindow().getDecorView().findViewById(android.R.id.content);
        frameLayout.addView(button);

        FrameLayout.LayoutParams layout= (FrameLayout.LayoutParams) button.getLayoutParams();
        layout.setMargins(100,120,0,0);
        layout.width = 200;
        layout.height = 200;
        button.setLayoutParams(layout);

添加一个Button,修改其高度、宽度、以及位置。

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!