Android How to set Remote RemoteView value?

I need to know code that allows me to set the weight of RemoteView.

I tried with this code, but this does not work:

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

Is there any way to do this? Many thanks....

+6
source share
1 answer

I think RemoteView has no weight property.

I'm not sure this will 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.

0
source

All Articles