OSDN Git Service

Adding padding to the folder content
authorSunny Goyal <sunnygoyal@google.com>
Wed, 13 May 2015 23:01:07 +0000 (16:01 -0700)
committerSunny Goyal <sunnygoyal@google.com>
Wed, 13 May 2015 23:01:26 +0000 (16:01 -0700)
Change-Id: I88e56ff1aa26282e0167e2599f1b34ee374b705f

res/layout/user_folder.xml
src/com/android/launcher3/FolderPagedView.java
src/com/android/launcher3/PagedView.java

index ab34917..ac5a88c 100644 (file)
@@ -38,6 +38,9 @@
             android:id="@+id/folder_content"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
+            android:paddingLeft="4dp"
+            android:paddingRight="4dp"
+            android:paddingTop="4dp"
             launcher:pageIndicator="@+id/folder_page_indicator" />
     </FrameLayout>
 
index a6494d2..125de3f 100644 (file)
@@ -237,13 +237,13 @@ public class FolderPagedView extends PagedView {
         page.setInvertIfRtl(true);
         page.setGridSize(mGridCountX, mGridCountY);
 
-        LayoutParams lp = generateDefaultLayoutParams();
-        lp.isFullScreenPage = true;
-        addView(page, -1, lp);
+        addView(page, -1, generateDefaultLayoutParams());
         return page;
     }
 
     public void setFixedSize(int width, int height) {
+        width -= (getPaddingLeft() + getPaddingRight());
+        height -= (getPaddingTop() + getPaddingBottom());
         for (int i = getChildCount() - 1; i >= 0; i --) {
             ((CellLayout) getChildAt(i)).setFixedSize(width, height);
         }
@@ -339,11 +339,13 @@ public class FolderPagedView extends PagedView {
     }
 
     public int getDesiredWidth() {
-        return getPageCount() > 0 ? getPageAt(0).getDesiredWidth() : 0;
+        return getPageCount() > 0 ?
+                (getPageAt(0).getDesiredWidth() + getPaddingLeft() + getPaddingRight()) : 0;
     }
 
     public int getDesiredHeight()  {
-        return  getPageCount() > 0 ? getPageAt(0).getDesiredHeight() : 0;
+        return  getPageCount() > 0 ?
+                (getPageAt(0).getDesiredHeight() + getPaddingTop() + getPaddingBottom()) : 0;
     }
 
     public int getItemCount() {
index c8e7d9c..e27ea64 100644 (file)
@@ -900,7 +900,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
                     pageGap = getPaddingRight();
                 }
 
-                childLeft += childWidth + pageGap;
+                childLeft += childWidth + pageGap
+                        + (lp.isFullScreenPage ? 0 : (getPaddingLeft() + getPaddingRight()));
             }
         }