Android(安卓)Launcher3一些默认修改
16lz
2021-12-04
1.如何设置默认页
1 2 3 4 5 | res/values/Config.xml 在Launcher3 桌面,不管在哪一页,按HOME 键,会回到默认页。 |
2.如何隐藏launcher3中的搜索框
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 1 . 在Launcher3/src/com/android/launcher3/Launcher.java中 注释updateGlobalIcons()方法调用,共两处。 public View getQsbBar() { if (mQsbBar == null ) { mQsbBar = mInflater.inflate(R.layout.search_bar, mSearchDropTargetBar, false ); - mSearchDropTargetBar.addView(mQsbBar); } + mQsbBar.setVisibility(View.GONE); return mQsbBar; } @Override public void bindSearchablesChanged() { //注释该方法内容 /* boolean searchVisible = updateGlobalSearchIcon(); boolean voiceVisible = updateVoiceSearchIcon(searchVisible); if (mSearchDropTargetBar != null) { mSearchDropTargetBar.onSearchPackagesChanged(searchVisible, voiceVisible); } */ } 2 . 在Launcher3/src/com/android/launcher3/DynamicGrid.java中 // Layout the search bar //注释如下内容 /* View qsbBar = launcher.getQsbBar(); LayoutParams vglp = qsbBar.getLayoutParams(); vglp.width = LayoutParams.MATCH_PARENT; vglp.height = LayoutParams.MATCH_PARENT; qsbBar.setLayoutParams(vglp); */ 3 . 在Launcher3/res/values/dimens.xml中 - + 重新编译后即可看到效果。 |
3.如何调整原生Launcher3主界面的search框的大小?
1 2 3 4 5 6 | 修改如下: 定位打/packages/apps/Launcher3/res/values/dimens.xml。 //修改这个可以调整search框距离顶部距离。 //search框的宽度,一般不需要调整。 //search框的高度,不要调整为0,删除按钮需要占用一部分空间。 |
4.让主菜单部分应用按指定顺序排在前面?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 添加res/values/arrays.xml:需要排序的应用:这里的item 内容一定要填写正确,否则会匹配不上,无法参与排序。 src/com/android/launcher3/Utilities.java + import java.util.Arrays; + import java.util.List; + public static List final Context context) { + return Arrays.asList(context.getResources().getStringArray(R.array.apps_componentName)); + } src/com/android/launcher3/LauncherModel.java protected int mPreviousConfigMcc; + static List new ArrayList LauncherModel(LauncherAppState app, IconCache iconCache, AppFilter appFilter) { ...... mUserManager = UserManagerCompat.getInstance(context); + appArray = Utilities.getAppsComponentName(context); } 添加如下sortApps 方法:apps 按arrays.xml 排序,在原来的排序基础上,将arrays.xml 配置的应用按顺序排在前面。 public static final void sortApps(ArrayList apps) { int length = appArray.size(); List assignApps = new ArrayList(); for ( int i= 0 ;i |
5.如何确定待机HOME界面布局使用的是哪个default_workspace文件?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | src/com/android/launcher3/DynamicGrid.java 选择哪个default_workspace 和 public DynamicGrid(Context context, Resources resources, int minWidthPx, int minHeightPx, int widthPx, int heightPx, int awPx, int ahPx)中的minWidthPx 和minHeightPx minWidthPx 、minHeightPx 值转换为dpi之后 ,deviceProfiles 列表与其进行比较,选择与当前屏幕大小最接近的deviceProfiles 的 详细解释如下: src/com/android/launcher3/DynamicGrid.java中 1 .deviceProfiles 列表如下: deviceProfiles.add( new DeviceProfile( "Super Short Stubby" , 255 , 300 , 2 , 3 , 48 , 13 , (hasAA ? 3 : 5 ), 48 , R.xml.default_workspace_4x4)); deviceProfiles.add( new DeviceProfile( "Shorter Stubby" , 255 , 400 , 3 , 3 , 48 , 13 , (hasAA ? 3 : 5 ), 48 , R.xml.default_workspace_4x4)); deviceProfiles.add( new DeviceProfile( "Short Stubby" , 275 , 420 , 3 , 4 , 48 , 13 , (hasAA ? 5 : 5 ), 48 , R.xml.default_workspace_4x4)); deviceProfiles.add( new DeviceProfile( "Stubby" , 255 , 450 , 3 , 4 , 48 , 13 , (hasAA ? 5 : 5 ), 48 , R.xml.default_workspace_4x4)); deviceProfiles.add( new DeviceProfile( "Nexus S" , 296 , 491 .33f, 4 , 4 , 48 , 13 , (hasAA ? 5 : 5 ), 48 , R.xml.default_workspace_4x4)); deviceProfiles.add( new DeviceProfile( "Nexus 4" , 335 , 567 , 4 , 4 , DEFAULT_ICON_SIZE_DP, 13 , (hasAA ? 5 : 5 ), 56 , R.xml.default_workspace_4x4)); deviceProfiles.add( new DeviceProfile( "Nexus 5" , 359 , 567 , 4 , 4 , DEFAULT_ICON_SIZE_DP, 13 , (hasAA ? 5 : 5 ), 56 , R.xml.default_workspace_4x4)); deviceProfiles.add( new DeviceProfile( "Large Phone" , 406 , 694 , 5 , 5 , 64 , 14 .4f, 5 , 56 , R.xml.default_workspace_5x5)); // The tablet profile is odd in that the landscape orientation // also includes the nav bar on the side deviceProfiles.add( new DeviceProfile( "Nexus 7" , 575 , 904 , 5 , 6 , 72 , 14 .4f, 7 , 60 , R.xml.default_workspace_5x6)); // Larger tablet profiles always have system bars on the top & bottom deviceProfiles.add( new DeviceProfile( "Nexus 10" , 727 , 1207 , 5 , 6 , 76 , 14 .4f, 7 , 64 , R.xml.default_workspace_5x6)); deviceProfiles.add( new DeviceProfile( "20-inch Tablet" , 1527 , 2527 , 7 , 7 , 100 , 20 , 7 , 72 , R.xml.default_workspace_4x4)); 2 .重新计算MinWidth 和MinHeigh 单位是dpi。 mMinWidth = dpiFromPx(minWidthPx, dm); mMinHeight = dpiFromPx(minHeightPx, dm); 3 .创建mProfile,mProfile.defaultLayoutId 就是最终Home界面使用的default_workspace 的id。 mProfile中的defaultLayoutId 是哪个default_workspace 见DeviceProfile.java。 mProfile = new DeviceProfile(context, deviceProfiles, mMinWidth, mMinHeight, widthPx, heightPx, awPx, ahPx, resources); src/com/android/launcher3/DeviceProfile.java DeviceProfile(Context context, ArrayList float minWidth, float minHeight, int wPx, int hPx, int awPx, int ahPx, Resources res) { 方法中: 4 .用屏幕宽高创建的点(PointF xy = new PointF(width, height))与 deviceProfiles中的w 和 h 创建的点 new PointF(widthDps, heightDps))进行比较,也就是从deviceProfiles 列表中找出和当前屏幕大小最接近的deviceProfiles。 DeviceProfile closestProfile = findClosestDeviceProfile(minWidth, minHeight, points); ...... 5 .采用和当前屏幕大小最接近的deviceProfiles的default_workspace defaultLayoutId = closestProfile.defaultLayoutId; |
6.如何替换第三方应用在launcher上显示的图标?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 在launcher/src/com/android/launcher3/IconCache.java中修改, private CacheEntry cacheLocked(ComponentName componentName, ResolveInfo info, private CacheEntry cacheLocked(ComponentName componentName, ResolveInfo info, HashMap |
7.如何去掉Launcher3的开机引导页面?
1 2 3 4 5 6 7 8 | 修改方案如下: 请定位到src/com/android/launcher3/LauncherClings.java文件: class LauncherClings implements OnClickListener { ...... private static final String TAG_CROP_TOP_AND_SIDES = "crop_bg_top_and_sides - private static final boolean DISABLE_CLINGS = false ; + private static final boolean DISABLE_CLINGS = true ; |
8.为何Launcher3设置一些壁纸后,壁纸显示比预览图模糊?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 预览的时候,没有做格式转化,所以显示正常! 在设置壁纸的时候,默认是采用jpeg格式转换的,导致转换后损耗了一些,设置壁纸后,某些对比度比较高的壁纸就显示的模糊! 修改方案: 默认修改为采用png格式转换! android6. 0 之前的版本,请做如下修改: 定位到/packages/apps/Launcher3/的WallpaperCropActivity.java文件 1 、String mOutputFormat = "jpg" ; //修改为"png" 2 、 protected static String getFileExtension(String requestFormat) { String outputFormat = (requestFormat == null ) ? "jpg" //修改为"png" : requestFormat; outputFormat = outputFormat.toLowerCase(); return (outputFormat.equals( "png" ) || outputFormat.equals( "gif" )) ? "png" // We don't support gif compression. : "jpg" ; } android6. 0 的版本,请做如下修改: 定位到/packages/apps/Launcher3/WallpaperPicker/src/com/android/gallery3d/common/BitmapCropTask.java文件 if (crop.compress(CompressFormat.JPEG, DEFAULT_COMPRESS_QUALITY, tmpOut)) 修改为: if (crop.compress(CompressFormat.PNG, DEFAULT_COMPRESS_QUALITY, tmpOut)) |
9.6.0平台上Launcher3自带的壁纸路径是什么?
1 2 3 4 5 6 | 在 6.0 中,平台版本预置了一些壁纸资源,相关路径如下: 资源文件在: packages/apps/Launcher3/WallpaperPicker/res/drawable-xhdpi/ 字串文件在: packages/apps/Launcher3/WallpaperPicker/res/values-nodpi/wallpapers.xml |
更多相关文章
- Android控件之Textiew的使用
- android 5.1禁止休眠
- Android(安卓)Zxing修改为竖屏扫描,和连续扫描问题
- Android出现adb device offline
- Transport endpoint is not connected 报错
- Android(安卓)kernel 下载编译笔记
- Android(安卓)studio 打包apk如何重命名apk名称
- Android(安卓)隐式调用 intent
- 完美解决android Studio打开报错 https://code.google.com/p/and