OSDN Git Service

FloatingToolbar: Make it more obvious that there are more items in the overflow.
authorAbodunrinwa Toki <toki@google.com>
Wed, 23 Mar 2016 15:56:43 +0000 (15:56 +0000)
committerAbodunrinwa Toki <toki@google.com>
Wed, 23 Mar 2016 19:02:32 +0000 (19:02 +0000)
1. Make the overflow show part of the items hidden behind the scroll view
2. Increase the time the scrollbar is on screen so users are less likely to miss it

Bug: 27427333
Change-Id: Ia0bff5fa29cba3103263bc7d063176b0ba7ff7b9

core/java/com/android/internal/widget/FloatingToolbar.java

index 8682030..da223a6 100644 (file)
@@ -41,6 +41,7 @@ import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.MeasureSpec;
 import android.view.View.OnLayoutChangeListener;
+import android.view.ViewConfiguration;
 import android.view.ViewGroup;
 import android.view.ViewTreeObserver;
 import android.view.Window;
@@ -878,6 +879,10 @@ public final class FloatingToolbar {
                     .start();
         }
 
+        /**
+         * Defines the position of the floating toolbar popup panels when transition animation has
+         * stopped.
+         */
         private void setPanelsStatesAtRestingPosition() {
             mOverflowButton.setEnabled(true);
             mOverflowPanel.awakenScrollBars();
@@ -1236,7 +1241,15 @@ public final class FloatingToolbar {
                     Math.min(
                             Math.max(MIN_OVERFLOW_SIZE, maxItemSize),
                             mOverflowPanel.getCount()));
-            return actualSize * getLineHeight(mContext) + mOverflowButtonSize.getHeight();
+            int extension = 0;
+            if (actualSize < mOverflowPanel.getCount()) {
+                // The overflow will require scrolling to get to all the items.
+                // Extend the height so that part of the hidden items is displayed.
+                extension = (int) (getLineHeight(mContext) * 0.5f);
+            }
+            return actualSize * getLineHeight(mContext)
+                    + mOverflowButtonSize.getHeight()
+                    + extension;
         }
 
         private void setButtonTagAndClickListener(View menuItemButton, MenuItem menuItem) {
@@ -1446,6 +1459,7 @@ public final class FloatingToolbar {
             OverflowPanel(FloatingToolbarPopup popup) {
                 super(Preconditions.checkNotNull(popup).mContext);
                 this.mPopup = popup;
+                setScrollBarDefaultDelayBeforeFade(ViewConfiguration.getScrollDefaultDelay() * 3);
             }
 
             @Override