Android How to setWeight of a RemoteView?
Asked Answered
C

1

6

I need to know the code that allow me to set the Weight of a RemoteView.

I tried with this code but this doesn't work:

RemoteViews remoteViews = new RemoteViews(c.getPackageName(), R.layout.notification);
remoteViews.setInt(R.id.ll_notification, "setWeight", 12);

There is a way to do this? Many thanks....

Carolanncarole answered 21/7, 2012 at 21:11 Comment(0)
Y
-1

I think RemoteView does not have a weight property.

I am not sure that is going to work but give it a try.

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

Good luck.

Yeasty answered 4/7, 2014 at 5:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.