6

我需要知道允许我设置 RemoteView 权重的代码。

我尝试使用此代码,但这不起作用:

RemoteViews remoteViews = new RemoteViews(c.getPackageName(), R.layout.notification);
remoteViews.setInt(R.id.ll_notification, "setWeight", 12);

有办法做到这一点吗?非常感谢....

4

1 回答 1

0

我认为 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);

祝你好运。

于 2014-07-04T05:38:05.270 回答