【问题标题】:Android How to setWeight of a RemoteView?Android 如何设置 RemoteView 的重量?
【发布时间】:2012-07-21 21:11:26
【问题描述】:
我需要知道允许我设置 RemoteView 权重的代码。
我尝试使用此代码,但这不起作用:
RemoteViews remoteViews = new RemoteViews(c.getPackageName(), R.layout.notification);
remoteViews.setInt(R.id.ll_notification, "setWeight", 12);
有办法做到这一点吗?
非常感谢....
【问题讨论】:
标签:
android
android-layout-weight
remoteview
【解决方案1】:
我认为 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);
祝你好运。