在动态添加RemoteViews重布局

编程入门 行业动态 更新时间:2024-10-23 13:34:09
本文介绍了在动态添加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?

推荐答案

请参阅: developer.android/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重布局

本文发布于:2023-11-11 18:07:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579183.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:布局   动态   RemoteViews

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!