美文网首页
Android O 主界面和所有应用界面行和列的修改

Android O 主界面和所有应用界面行和列的修改

作者: wyman_wu | 来源:发表于2018-12-19 17:58 被阅读0次

Android 8.1中\alps\packages\apps\Launcher3\src\com\android\launcher3\InvariantDeviceProfile.java
控制着行和列的实现。

public InvariantDeviceProfile(InvariantDeviceProfile p) {

        this(p.name, p.minWidthDps, p.minHeightDps, p.numRows, p.numColumns,

                p.numFolderRows, p.numFolderColumns, p.minAllAppsPredictionColumns,

                p.iconSize, p.landscapeIconSize, p.iconTextSize, p.numHotseatIcons,

                p.defaultLayoutId, p.demoModeLayoutId);

    }

    InvariantDeviceProfile(String n, float w, float h, int r, int c, int fr, int fc, int maapc,

            float is, float lis, float its, int hs, int dlId, int dmlId) {

        name = n;

        minWidthDps = w;

        minHeightDps = h;

        numRows = r;

        numColumns = c;

        numFolderRows = fr;

        numFolderColumns = fc;

        minAllAppsPredictionColumns = maapc;

        iconSize = is;

        landscapeIconSize = lis;

        iconTextSize = its;

        numHotseatIcons = hs;

        defaultLayoutId = dlId;

        demoModeLayoutId = dmlId;

    }

p.name, p.minWidthDps, p.minHeightDps, p.numRows, p.numColumns,p.numFolderRows, p.numFolderColumns, p.minAllAppsPredictionColumns, p.iconSize, p.landscapeIconSize, p.iconTextSize, p.numHotseatIcons,p.defaultLayoutId, p.demoModeLayoutId这些分别是界面的一些信息。
p.numRows, p.numColumns,p.numHotseatIcons控制着主界面和所有应用界面的行和列。

ArrayList<InvariantDeviceProfile> getPredefinedDeviceProfiles(Context context) {
        ArrayList<InvariantDeviceProfile> 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),
                            5,//wy
                            6,//wy
                            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),
                            6,//wy
                            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;
    }

在new InvariantDeviceProfile()中修改想要的信息即可。

相关文章

网友评论

      本文标题:Android O 主界面和所有应用界面行和列的修改

      本文链接:https://www.haomeiwen.com/subject/slxjkqtx.html