Adding some spacing between overview panel items
Bug: 18293488 Change-Id: I8731c4d2ad34571a4a3a21b03a5fbae0ba66332f
This commit is contained in:
parent
b1b201c9af
commit
8dfe2da698
|
@ -25,8 +25,8 @@
|
|||
<dimen name="dynamic_grid_workspace_page_spacing">8dp</dimen>
|
||||
<dimen name="dynamic_grid_overview_min_icon_zone_height">80dp</dimen>
|
||||
<dimen name="dynamic_grid_overview_max_icon_zone_height">120dp</dimen>
|
||||
<dimen name="dynamic_grid_overview_bar_item_width">48dp</dimen>
|
||||
<dimen name="dynamic_grid_overview_bar_spacer_width">68dp</dimen>
|
||||
<dimen name="dynamic_grid_overview_bar_item_width">80dp</dimen>
|
||||
<dimen name="dynamic_grid_overview_bar_spacer_width">20dp</dimen>
|
||||
|
||||
<!-- Cling -->
|
||||
<dimen name="cling_migration_logo_height">240dp</dimen>
|
||||
|
|
|
@ -33,6 +33,7 @@ import android.view.Surface;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.ViewGroup.MarginLayoutParams;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -703,11 +704,6 @@ public class DeviceProfile {
|
|||
return visibleChildren;
|
||||
}
|
||||
|
||||
int calculateOverviewModeWidth(int visibleChildCount) {
|
||||
return visibleChildCount * overviewModeBarItemWidthPx +
|
||||
(visibleChildCount-1) * overviewModeBarSpacerWidthPx;
|
||||
}
|
||||
|
||||
public void layout(Launcher launcher) {
|
||||
FrameLayout.LayoutParams lp;
|
||||
Resources res = launcher.getResources();
|
||||
|
@ -872,10 +868,38 @@ public class DeviceProfile {
|
|||
Rect r = getOverviewModeButtonBarRect();
|
||||
lp = (FrameLayout.LayoutParams) overviewMode.getLayoutParams();
|
||||
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
|
||||
lp.width = Math.min(availableWidthPx,
|
||||
calculateOverviewModeWidth(getVisibleChildCount(overviewMode)));
|
||||
|
||||
int visibleChildCount = getVisibleChildCount(overviewMode);
|
||||
int totalItemWidth = visibleChildCount * overviewModeBarItemWidthPx;
|
||||
int maxWidth = totalItemWidth + (visibleChildCount-1) * overviewModeBarSpacerWidthPx;
|
||||
|
||||
lp.width = Math.min(availableWidthPx, maxWidth);
|
||||
lp.height = r.height();
|
||||
overviewMode.setLayoutParams(lp);
|
||||
|
||||
if (lp.width > totalItemWidth && visibleChildCount > 1) {
|
||||
// We have enough space. Lets add some margin too.
|
||||
int margin = (lp.width - totalItemWidth) / (visibleChildCount-1);
|
||||
View lastChild = null;
|
||||
|
||||
// Set margin of all visible children except the last visible child
|
||||
for (int i = 0; i < visibleChildCount; i++) {
|
||||
if (lastChild != null) {
|
||||
MarginLayoutParams clp = (MarginLayoutParams) lastChild.getLayoutParams();
|
||||
if (isLayoutRtl) {
|
||||
clp.leftMargin = margin;
|
||||
} else {
|
||||
clp.rightMargin = margin;
|
||||
}
|
||||
lastChild.setLayoutParams(clp);
|
||||
lastChild = null;
|
||||
}
|
||||
View thisChild = overviewMode.getChildAt(i);
|
||||
if (thisChild.getVisibility() != View.GONE) {
|
||||
lastChild = thisChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue