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....

Luuklag
  • 3,897
  • 11
  • 38
  • 57
Meroelyth
  • 5,310
  • 9
  • 42
  • 52

1 Answers1

-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.

Emre Aktürk
  • 3,306
  • 2
  • 18
  • 30