Mer*_*yth 6 android remoteview android-layout-weight
我需要知道允许我设置RemoteView权重的代码.
我尝试使用此代码,但这不起作用:
RemoteViews remoteViews = new RemoteViews(c.getPackageName(), R.layout.notification);
remoteViews.setInt(R.id.ll_notification, "setWeight", 12);
Run Code Online (Sandbox Code Playgroud)
有办法做到这一点?非常感谢....
Emr*_*ürk -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);
Run Code Online (Sandbox Code Playgroud)
祝你好运。
| 归档时间: |
|
| 查看次数: |
694 次 |
| 最近记录: |