本文介绍了Android的如何setWeight一个远程视窗的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道code,让我来设置远程视窗的重量。

I need to know the code that allow me to set the Weight of a RemoteView.

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

I tried with this code but this doesn't work:

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

有一种方法可以做到这一点?
非常感谢....

There is a way to do this?Many thanks....

推荐答案

我觉得远程视窗没有一个体重属性。

I think RemoteView does not have a weight property.

我不知道那是去工作,但不妨一试。

I am not sure that is going to work but give it a try.

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

祝你好运。

这篇关于Android的如何setWeight一个远程视窗的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 22:46