我需要知道允许我设置RemoteView权重的代码。
我试着使用下面的代码,但这不起作用:
RemoteViews remoteViews = new RemoteViews(c.getPackageName(), R.layout.notification);
remoteViews.setInt(R.id.ll_notification, "setWeight", 12);有办法做到这一点吗?非常感谢....
发布于 2014-07-04 13:38:05
我认为RemoteView没有权重属性。
我不确定这是否会奏效,但请试一试。
RemoteViews remoteViews = new RemoteViews("", 0);
LinearLayout.LayoutParams tempLayoutParams =new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
tempLayoutParams.weight = 1.0f;
LinearLayout tempLinearLayout = new LinearLayout(getContext()):
tempLinearLayout.setLayoutParams(tempLayoutParams);
tempLinearLayout.addView(remoteViews);祝好运。
https://stackoverflow.com/questions/11595883
复制相似问题