Android如何设置RemoteView的权限?

时间:2012-07-21 21:11:26

标签: android android-layout-weight remoteview

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

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

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

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

1 个答案:

答案 0 :(得分: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);
祝你好运。