2012-07-21 30 views
5

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

我试着用这个代码,但这个不起作用:

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

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

回答

0

我认为RemoteView没有weight属性。

我不确定这是行不行的,但试试看。

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); 

祝你好运。

相关问题