Android13 Launcher3屏蔽桌面指示器

最近需求是要求隐藏桌面上的分页指示器(提示左右滑动 分页点或横线)看到Launcher3里面相关类是PageIndicator。没有找到该view设置隐藏,但是找到了一个新的方案

    隐藏桌面圆点指示器
    
    Change-Id: I44fd51d3662247926d5550346b7b62b2e264086a

diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 6976a79e0f..5e3c2d35e1 100755
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -285,6 +285,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
         mContent.setFolder(this);
 
         mPageIndicator = findViewById(R.id.folder_page_indicator);
+        mPageIndicator.setVisibility(View.INVISIBLE);
         mFolderName = findViewById(R.id.folder_name);
         mFolderName.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp.folderLabelTextSizePx);
         mFolderName.setOnBackKeyListener(this);
diff --git a/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java b/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java
index 1681ea5758..594ad9d9b8 100644
--- a/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java
+++ b/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java
@@ -141,8 +141,8 @@ public class WorkspacePageIndicator extends View implements Insettable, PageIndi
         int lineLeft = (int) (progress * (availableWidth - lineWidth));
         int lineRight = lineLeft + lineWidth;
 
-        canvas.drawRoundRect(lineLeft, getHeight() / 2 - mLineHeight / 2, lineRight,
-                getHeight() / 2 + mLineHeight / 2, mLineHeight, mLineHeight, mLinePaint);
+        // canvas.drawRoundRect(lineLeft, getHeight() / 2 - mLineHeight / 2, lineRight,
+        //         getHeight() / 2 + mLineHeight / 2, mLineHeight, mLineHeight, mLinePaint);
     }
 
     @Override
diff --git a/src/com/sprd/ext/pageindicators/WorkspacePageIndicatorDots.java b/src/com/sprd/ext/pageindicators/WorkspacePageIndicatorDots.java                                                  
index 4aa1c5afb5..4ffe9d54b8 100755                                                             
--- a/src/com/sprd/ext/pageindicators/WorkspacePageIndicatorDots.java                           
+++ b/src/com/sprd/ext/pageindicators/WorkspacePageIndicatorDots.java                           
@@ -63,24 +63,26 @@ public class WorkspacePageIndicatorDots extends WorkspaceBasePageIndicator {
     protected void onDraw(Canvas canvas) {                                                     
         int availableWidth = getWidth();                                                       
         //Recalculate dot radius size                                                          
-        mDotRadius = Math.min(MAX_DOTRADIUS, (float) availableWidth / (3 * mNumPages - 1));    
-                                                                                               
-        float circleGap = 3 * mDotRadius;                                                      
-        // Draw all page indicators;                                                           
-        float startX = (availableWidth - mNumPages * circleGap + mDotRadius) / 2;              
-        float x = startX + mDotRadius;                                                         
-        float y = (float) canvas.getHeight() / 2;                                              
-                                                                                               
-        if (mIsRtl) {                                                                          
-            x = availableWidth - x;                                                            
-            circleGap = -circleGap;                                                            
-        }                                                                                      
-        mCirclePaint.setColor(mActiveColor);                                                   
-        for (int i = 0; i < mNumPages; i++) {                                                  
-            mCirclePaint.setAlpha((i == mActivePage ? mActiveAlpha : mInActiveAlpha));         
-            canvas.drawCircle(x, y, mDotRadius, mCirclePaint);                                 
-            x += circleGap;                                                                    
-        }                                                                                      
+        //^M                                                                                   
+        //隐藏桌面圆点指示器^M                                                                 
+        // mDotRadius = Math.min(MAX_DOTRADIUS, (float) availableWidth / (3 * mNumPages - 1)); 
^M                                                                                              
+^M                                                                                             
+        // float circleGap = 3 * mDotRadius;^M                                                 
+        // // Draw all page indicators;^M                                                      
+        // float startX = (availableWidth - mNumPages * circleGap + mDotRadius) / 2;^M         
+        // float x = startX + mDotRadius;^M                                                    
+        // float y = (float) canvas.getHeight() / 2;^M                                         
+^M                                                                                             
+        // if (mIsRtl) {^M                                                                     
+        //     x = availableWidth - x;^M                                                       
+        //     circleGap = -circleGap;^M                                                       
+        // }^M                                                                                 
+        // }^M
+        // mCirclePaint.setColor(mActiveColor);^M                                              
+        // for (int i = 0; i < mNumPages; i++) {^M                                             
+        //     mCirclePaint.setAlpha((i == mActivePage ? mActiveAlpha : mInActiveAlpha));^M    
+        //     canvas.drawCircle(x, y, mDotRadius, mCirclePaint);^M                            
+        //     x += circleGap;^M                                                               
+        // }^M                                                                                 
+        //^M
+        //隐藏桌面圆点指示器^M
+        // mDotRadius = Math.min(MAX_DOTRADIUS, (float) availableWidth / (3 * mNumPages - 1));
^M
+^M
+        // float circleGap = 3 * mDotRadius;^M
+        // // Draw all page indicators;^M
+        // float startX = (availableWidth - mNumPages * circleGap + mDotRadius) / 2;^M
+        // float x = startX + mDotRadius;^M
+        // float y = (float) canvas.getHeight() / 2;^M
+^M
+        // if (mIsRtl) {^M
+        //     x = availableWidth - x;^M
+        //     circleGap = -circleGap;^M
+        // }^M
+        // mCirclePaint.setColor(mActiveColor);^M
+        // for (int i = 0; i < mNumPages; i++) {^M
+        //     mCirclePaint.setAlpha((i == mActivePage ? mActiveAlpha : mInActiveAlpha));^M
+        //     canvas.drawCircle(x, y, mDotRadius, mCirclePaint);^M
+        //     x += circleGap;^M
+        // }^M
     } 

以上就是分两个部分,一个是文件夹中的指示器隐藏,一个是桌面的隐藏。

总结:他的指示器圆点(横线)是用view的ondraw方法绘制出来的,我们在这个地方注释其逻辑,禁止其绘制就可以了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值