Android8.1 Launcher3客制化 修改行数和列数

上层逻辑代码:packages/apps/Launcher3/src/com/android/launcher3/InvariantDeviceProfile.java 

ArrayList getPredefinedDeviceProfiles(Context context) {
        ArrayList profiles = new ArrayList<>();
        try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) {
            final int depth = parser.getDepth();
            int type;

            while (((type = parser.next()) != XmlPullParser.END_TAG ||
                    parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
                if ((type == XmlPullParser.START_TAG) && "profile".equals(parser.getName())) {
                    TypedArray a = context.obtainStyledAttributes(
                            Xml.asAttributeSet(parser), R.styleable.InvariantDeviceProfile);
                    int numRows = a.getInt(R.styleable.InvariantDeviceProfile_numRows, 0);
                    int numColumns = a.getInt(R.styleable.InvariantDeviceProfile_numColumns, 0);
                    float iconSize = a.getFloat(R.styleable.InvariantDeviceProfile_iconSize, 0);
                    profiles.add(new InvariantDeviceProfile(
                            a.getString(R.styleable.InvariantDeviceProfile_name),
                            a.getFloat(R.styleable.InvariantDeviceProfile_minWidthDps, 0),
                            a.getFloat(R.styleable.InvariantDeviceProfile_minHeightDps, 0),
                            numRows,
                            numColumns,
                            a.getInt(R.styleable.InvariantDeviceProfile_numFolderRows, numRows),
                            a.getInt(R.styleable.InvariantDeviceProfile_numFolderColumns, numColumns),
                            a.getInt(R.styleable.InvariantDeviceProfile_minAllAppsPredictionColumns, numColumns),
                            iconSize,
                            a.getFloat(R.styleable.InvariantDeviceProfile_landscapeIconSize, iconSize),
                            a.getFloat(R.styleable.InvariantDeviceProfile_iconTextSize, 0),
                            a.getInt(R.styleable.InvariantDeviceProfile_numHotseatIcons, numColumns),
                            a.getResourceId(R.styleable.InvariantDeviceProfile_defaultLayoutId, 0),
                            a.getResourceId(R.styleable.InvariantDeviceProfile_demoModeLayoutId, 0)));
                    a.recycle();
                }
            }
        } catch (IOException|XmlPullParserException e) {
            throw new RuntimeException(e);
        }
        return profiles;
    }

从R.xml.device_profiles这个文件中读取数据,查找xml文件,go版本该文件在./go/res/xml/device_profiles.xml 

--- a/alps/packages/apps/Launcher3/go/res/xml/device_profiles.xml
+++ b/alps/packages/apps/Launcher3/go/res/xml/device_profiles.xml
@@ -22,12 +22,12 @@
         launcher:minWidthDps="296"
         launcher:minHeightDps="491.33"
         launcher:numRows="4"
-        launcher:numColumns="4"
-        launcher:numFolderRows="4"
-        launcher:numFolderColumns="4"
-        launcher:iconSize="60"
+        launcher:numColumns="3"
+        launcher:numFolderRows="3"
+        launcher:numFolderColumns="3"
+        launcher:iconSize="80"
         launcher:iconTextSize="14.0"
-        launcher:defaultLayoutId="@xml/default_workspace_4x4"
+        launcher:defaultLayoutId="@xml/default_workspace_3x3"
         />
 
 

 

你可能感兴趣的:(MTK随记)