How to Get Widget Widget Size

  android, question

图片描述

As shown in the figure, I want to know how to obtain the width and height of the widget after each adjustment.

I have two thoughts at present:
1. Get it through RemoteViews or AppWidgetManager inside in some way;

2. To obtain a certain system parameter, we can know how many times the current Launcher layout is, and the width and height of each grid. For example, Launcher is currently a 4×4 layout. knowing the size of each 4×4 grid, you can know how high and how wide each row is, and you can also know the height and width of the widget after each adjustment.

Then the question arises, and the train of thought is yes, but how can it be realized? Everyone help:)

public List<Object> getSortedWidgets(int pos) {

ArrayList<Object> allList = new ArrayList<Object>();
 allList = mWidgetsList.get(mPackageItemInfos.get(pos));
 ArrayList<Object> infoList = new ArrayList<Object>();
 //added by zhanling 2016.02.16
 for (int i = 0;   i < allList.size();  I plus)
 Object o = allList.get(i);
 if (o instanceof LauncherAppWidgetProviderInfo) {
 LauncherAppWidgetProviderInfo info = (LauncherAppWidgetProviderInfo) allList.get(i);
 if (info.getSpanX(mLauncher) > profile.numColumns || info.getSpanY(mLauncher) > profile.numRows) {
 continue;
 bracket
 bracket
 infoList.add(o);
 bracket
 return infoList;
 bracket