在动态添加RemoteViews重布局 [英] Layout weight on dynamically added RemoteViews

查看:1693
本文介绍了在动态添加RemoteViews重布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的小工具,我用下面的动态添加项目(R.layout.widget_item)到我的主窗口部件的布局中定义一个LinearLayout中:

Within my widget, i'm using the following to dynamically add items (R.layout.widget_item) to a LinearLayout defined within my main widget layout:

//--  Main widget layout
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_design);

//--  Add to main layout
RemoteViews newView = new RemoteViews(context.getPackageName(), R.layout.widget_item);
views.addView(R.id.view_container, newView);

我的问题是,我怎么能动态设置?机器人:layout_weight属性的NewView的

My question is, how can I dynamically set the "android:layout_weight" attribute on the newView?

推荐答案

请参阅: http://developer.android.com/reference/android/widget/RemoteViews.html

NewView的在你的例子是阶级RemoteViews的实例,我不认为你可以轻松地设置超出什么​​RemoteViews提供什么。

newView in your example is an instance of class RemoteViews and I don't think you can easily set anything above and beyond what RemoteViews provides.

newView.setLayoutParams(layoutParams);

以上是行不通的,因为它不是RemoteViews的一部分。

The above will not work because it's not part of RemoteViews.

据我可以看到... ...可能会有一些四围设置和发现的尺寸和RemoteViews其他的LayoutParams的方式,但我还没有找到它。

As far as I can see... there may be some round about way of setting and finding dimensions and other layoutParams of RemoteViews, but I haven't found it yet.

这篇关于在动态添加RemoteViews重布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆