Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layout weight on dynamically added RemoteViews

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

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

like image 894
92Jacko Avatar asked Nov 26 '22 11:11

92Jacko


1 Answers

See: http://developer.android.com/reference/android/widget/RemoteViews.html

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

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

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.

like image 110
aseq Avatar answered Nov 29 '22 04:11

aseq