首页
IT
登录
6mi
u
盘
搜
搜 索
IT
Launcher3--launcher3 icon以及hotseat size大小修改
Launcher3--launcher3 icon以及hotseat size大小修改
xiaoxiao
2021-03-25
132
本帖最后由 wangjicong 于 2017-3-9 17:12 编辑
1.首先看icon大小的修改。 Launcher3在启动Launcher.java过程会先初始话一些列的参数配置。 1). Laucher.java @Override protected void onCreate(Bundle savedInstanceState) { if (DEBUG_STRICT_MODE) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads() .detectDiskWrites() .detectNetwork() // or .detectAll() for all detectable problems .penaltyLog() .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() .detectLeakedClosableObjects() .penaltyLog() .penaltyDeath() .build()); } if (mLauncherCallbacks != null) { mLauncherCallbacks.preOnCreate(); } super.onCreate(savedInstanceState); LauncherAppState.setApplicationContext(getApplicationContext()); LauncherAppState app = LauncherAppState.getInstance();
复制代码
Launcher.java 在oncreate的过程中,通过单例模式LauncherAppState.java来初始话。 上面
mInvariantDeviceProfile = new InvariantDeviceProfile(sContext);就是对页面布局,icon大小,hotseat 大小一些参数的自适。
<div> </div><div>private LauncherAppState() { if (sContext == null) { throw new IllegalStateException("LauncherAppState inited before app context set"); } Log.v(Launcher.TAG, "LauncherAppState inited"); if (sContext.getResources().getBoolean(R.bool.debug_memory_enabled)) { MemoryTracker.startTrackingMe(sContext, "L"); } mInvariantDeviceProfile = new InvariantDeviceProfile(sContext); mIconCache = new IconCache(sContext, mInvariantDeviceProfile); mWidgetCache = new WidgetPreviewLoader(sContext, mIconCache); mAppFilter = AppFilter.loadByName(sContext.getString(R.string.app_filter_class)); mBuildInfo = BuildInfo.loadByName(sContext.getString(R.string.build_info_class)); mModel = new LauncherModel(this, mIconCache, mAppFilter); LauncherAppsCompat.getInstance(sContext).addOnAppsChangedCallback(mModel); // Register intent receivers IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_LOCALE_CHANGED); filter.addAction(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED); filter.addAction(SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED); // For handling managed profiles filter.addAction(LauncherAppsCompat.ACTION_MANAGED_PROFILE_ADDED); filter.addAction(LauncherAppsCompat.ACTION_MANAGED_PROFILE_REMOVED); sContext.registerReceiver(mModel, filter); mUnreadInfoManager = new SprdUnreadInfoManager(this); SprdUnreadInfoManager.getInstance().init(this); }</div>
复制代码
修改icon大小:
在
InvariantDeviceProfile 的构造函数中:
iconSize = interpolatedDeviceProfileOut.iconSize; /*SUN:jicong.wang add for custom icon size start {@*/ String sunvov_custom_icon_size = context.getResources().getString(R.string.sunvov_icon_size); if (!"ignore".equals(sunvov_custom_icon_size)){ iconSize = Float.parseFloat(sunvov_custom_icon_size); } /*SUN:jicong.wang add for custom icon size end @}*/
复制代码
2.修改hotseat icon的大小:
在修改玩icon大小之后,发现shortcut icon的大小和主菜单中icon的大小同步变化了,但是hotseat icon的大小比icon的较大; 通过源码发现:CellLayout.java public boolean addViewToCellLayout(View child, int index, int childId, LayoutParams params, boolean markCells) { final LayoutParams lp = params; // Hotseat icons - remove text if (child instanceof BubbleTextView) { BubbleTextView bubbleChild = (BubbleTextView) child; bubbleChild.setTextVisibility(!mIsHotseat); } child.setScaleX(getChildrenScale()); child.setScaleY(getChildrenScale()); // Generate an id for each view, this assumes we have at most 256x256 cells // per workspace screen if (lp.cellX >= 0 && lp.cellX <= mCountX - 1 && lp.cellY >= 0 && lp.cellY <= mCountY - 1) { // If the horizontal or vertical span is set to -1, it is taken to // mean that it spans the extent of the CellLayout if (lp.cellHSpan < 0) lp.cellHSpan = mCountX; if (lp.cellVSpan < 0) lp.cellVSpan = mCountY; child.setId(childId); mShortcutsAndWidgets.addView(child, index, lp); if (markCells) markCellsAsOccupiedForView(child); return true; } return false; }
复制代码
通过上面发现在addview的过程中居然需要
child.setScaleX(getChildrenScale());
mHotseatScale = (float) grid.hotseatIconSizePx / grid.iconSizePx; 修改: final Resources res = getResources(); /*SUN:jicong.wang add for hotseat icon size same with shortcut icon start {@*/ if (!res.getBoolean(R.bool.sunvov_hotseat_shortcut_icon_size_same)){ mHotseatScale = (float) grid.hotseatIconSizePx / grid.iconSizePx; } /*SUN:jicong.wang add for hotseat icon size same with shortcut icon end @}*/
复制代码
转载请注明原文地址: https://ju.6miu.com/read-14225.html
技术
最新回复
(
0
)