Launcher3 定制桌面行列数

一.Launcher3默认显示行列数是通过device_profiles.xml这个文件配置的,文件内容是


<profiles xmlns:launcher="http://schemas.android.com/apk/res-auto" >

    <profile
        launcher:name="Super Short Stubby"
        launcher:minWidthDps="255"
        launcher:minHeightDps="300"
        launcher:numRows="2"
        launcher:numColumns="3"
        launcher:numFolderRows="2"
        launcher:numFolderColumns="3"
        launcher:minAllAppsPredictionColumns="3"
        launcher:iconSize="248"
        launcher:iconTextSize="13.0"
        launcher:numHotseatIcons="3"
        launcher:defaultLayoutId="@xml/default_workspace_3x3"
        />

    <profile
        launcher:name="Shorter Stubby"
        launcher:minWidthDps="255"
        launcher:minHeightDps="400"
        launcher:numRows="3"
        launcher:numColumns="3"
        launcher:numFolderRows="3"
        launcher:numFolderColumns="3"
        launcher:minAllAppsPredictionColumns="3"
        launcher:iconSize="48"
        launcher:iconTextSize="13.0"
        launcher:numHotseatIcons="3"
        launcher:defaultLayoutId="@xml/default_workspace_3x3"
        />

    <profile
        launcher:name="Short Stubby"
        launcher:minWidthDps="275"
        launcher:minHeightDps="420"
        launcher:numRows="3"
        launcher:numColumns="4"
        launcher:numFolderRows="3"
        launcher:numFolderColumns="4"
        launcher:minAllAppsPredictionColumns="4"
        launcher:iconSize="48"
        launcher:iconTextSize="13.0"
        launcher:numHotseatIcons="5"
        launcher:defaultLayoutId="@xml/default_workspace_4x4"
        />

    <profile
        launcher:name="Stubby"
        launcher:minWidthDps="255"
        launcher:minHeightDps="450"
        launcher:numRows="3"
        launcher:numColumns="4"
        launcher:numFolderRows="3"
        launcher:numFolderColumns="4"
        launcher:minAllAppsPredictionColumns="4"
        launcher:iconSize="48"
        launcher:iconTextSize="13.0"
        launcher:numHotseatIcons="5"
        launcher:defaultLayoutId="@xml/default_workspace_4x4"
        />

    <profile
        launcher:name="Nexus S"
        launcher:minWidthDps="296"
        launcher:minHeightDps="491.33"
        launcher:numRows="4"
        launcher:numColumns="4"
        launcher:numFolderRows="4"
        launcher:numFolderColumns="4"
        launcher:minAllAppsPredictionColumns="4"
        launcher:iconSize="48"
        launcher:iconTextSize="13.0"
        launcher:numHotseatIcons="5"
        launcher:defaultLayoutId="@xml/default_workspace_4x4"
        />

    <profile
        launcher:name="Nexus 4"
        launcher:minWidthDps="359"
        launcher:minHeightDps="567"
        launcher:numRows="4"
        launcher:numColumns="4"
        launcher:numFolderRows="4"
        launcher:numFolderColumns="4"
        launcher:minAllAppsPredictionColumns="4"
        launcher:iconSize="54"
        launcher:iconTextSize="13.0"
        launcher:numHotseatIcons="5"
        launcher:defaultLayoutId="@xml/default_workspace_4x4"
        />

    <profile
        launcher:name="Nexus 5"
        launcher:minWidthDps="335"
        launcher:minHeightDps="567"
        launcher:numRows="4"
        launcher:numColumns="4"
        launcher:numFolderRows="4"
        launcher:numFolderColumns="4"
        launcher:minAllAppsPredictionColumns="4"
        launcher:iconSize="54"
        launcher:iconTextSize="13.0"
        launcher:numHotseatIcons="5"
        launcher:defaultLayoutId="@xml/default_workspace_4x4"
        />

    <profile
        launcher:name="Large Phone"
        launcher:minWidthDps="406"
        launcher:minHeightDps="694"
        launcher:numRows="5"
        launcher:numColumns="5"
        launcher:numFolderRows="4"
        launcher:numFolderColumns="4"
        launcher:minAllAppsPredictionColumns="4"
        launcher:iconSize="56"
        launcher:iconTextSize="14.4"
        launcher:numHotseatIcons="5"
        launcher:defaultLayoutId="@xml/default_workspace_5x5"
        />

    <profile
        launcher:name="Nexus 7"
        launcher:minWidthDps="575"
        launcher:minHeightDps="904"
        launcher:numRows="5"
        launcher:numColumns="6"
        launcher:numFolderRows="4"
        launcher:numFolderColumns="5"
        launcher:minAllAppsPredictionColumns="4"
        launcher:iconSize="64"
        launcher:iconTextSize="14.4"
        launcher:numHotseatIcons="7"
        launcher:defaultLayoutId="@xml/default_workspace_5x6"
        />

    <profile
        launcher:name="Nexus 10"
        launcher:minWidthDps="727"
        launcher:minHeightDps="1207"
        launcher:numRows="2"
        launcher:numColumns="3"
        launcher:numFolderRows="4"
        launcher:numFolderColumns="5"
        launcher:minAllAppsPredictionColumns="4"
        launcher:iconSize="76"
        launcher:iconTextSize="14.4"
        launcher:numHotseatIcons="7"
        launcher:defaultLayoutId="@xml/default_workspace_5x6"
        />

    <profile
        launcher:name="20-inch Tablet"
        launcher:minWidthDps="1527"
        launcher:minHeightDps="2527"
        launcher:numRows="7"
        launcher:numColumns="7"
        launcher:numFolderRows="6"
        launcher:numFolderColumns="6"
        launcher:minAllAppsPredictionColumns="4"
        launcher:iconSize="100"
        launcher:iconTextSize="20.0"
        launcher:numHotseatIcons="7"
        launcher:defaultLayoutId="@xml/default_workspace_5x6"
        />

</profiles>

二.该配置文件是在InvariantDeviceProfile类的getPredefinedDeviceProfiles方法加载

 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);        Log.e("TAG", ">>>>>>>>>>>3>>>>"+numColumns+"#"+a.getString(R.styleable.InvariantDeviceProfile_name));
                    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;
    }

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Launcher3双层桌面指的是一种具有两个不同层级的桌面界面。这种设计可以提供更加灵活和个性化的桌面体验。 在Launcher3双层桌面中,通常会有两个主要的层级:上层桌面和下层桌面。上层桌面是我们平时使用的桌面界面,用于显示应用程序图标、小部件和壁纸等。用户可以在上层桌面上自定义排列应用程序图标、添加小部件以及更换壁纸等操作,以满足个性化需求。上层桌面可以通过滑动手势或者点击特定区域的按钮来访问下层桌面。 下层桌面通常用于展示更加高级和复杂的功能。它可以作为一个扩展或者补充上层桌面的功能工具。例如,用户可以将常用的设置、应用程序文件夹、搜索功能等放置在下层桌面上,以便于快速访问和使用。下层桌面还可以集成其他功用模块,如日历、天气等,帮助用户更加方便地获取信息。 通过使用Launcher3双层桌面,用户可以根据自己的喜好和需求对桌面界面进行个性化定制。无论是通过上层桌面上的排列图标还是下层桌面上的特殊功能,都能够使用户体验更加流畅和高效。双层桌面的设计还可以使用户更加方便地管理和组织应用程序和其他工具,提升整体的工作和娱乐效率。 总的来说,Launcher3双层桌面是一种拥有两个层级的桌面界面设计,可以提供更加灵活、个性化的桌面体验。通过上层桌面和下层桌面的结合,用户可以方便地管理应用程序、访问常用功能和获取相关信息,提升使用效率和满足个性化需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值