按钮 setLayoutParams 和 setDrawable Android

问题描述

android 按钮是否可以同时绘制 setLayoutParams 和 setBackground ?当我尝试这样做时,按钮总是消失。这是代码: '''

Button fullWidget = new Button(getActivity());
                        TableRow.LayoutParams lp = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,1f);
                        lp.setMargins(16,30,16,30);
                        lp.height = 600;
                        GradientDrawable shape = new GradientDrawable();
                        shape.setShape(GradientDrawable.RECTANGLE);
                        shape.setCornerRadius(15);
                        fullWidget.setText((String)sortedWidgets.getJSONObject(i).get("title"));
                        //((String)(sortedWidgets.getJSONObject(i).get("font_color")))
                        fullWidget.setTextColor(ColorUtil.stringToCol(((String)(sortedWidgets.getJSONObject(i).get("font_color")))));
                        fullWidget.setBackgroundColor(ColorUtil.stringToCol(((String)(sortedWidgets.getJSONObject(i).get("background_color")))));
                        fullWidget.setLayoutParams(lp);
                        fullWidget.setBackground(shape);

''' 谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)