diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index e8ae929a67824..e2ae7cfc4466b 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -105,6 +105,12 @@
so the width of the icon should be 13.0dp * (12.0 / 20.0) -->
7.8dp
+
+ 1dp
+
14sp
diff --git a/packages/SystemUI/src/com/android/systemui/battery/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/battery/BatteryMeterView.java
index d301858505b9f..4c16566fff8fc 100644
--- a/packages/SystemUI/src/com/android/systemui/battery/BatteryMeterView.java
+++ b/packages/SystemUI/src/com/android/systemui/battery/BatteryMeterView.java
@@ -378,14 +378,26 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver {
float fullBatteryIconWidth =
BatterySpecs.getFullBatteryWidth(mainBatteryWidth, displayShield);
- // TODO(b/255625888): Add some marginTop so that, even when the battery icon has the shield,
- // the bottom of the main icon is still aligned with the bottom of all the other icons.
+ int marginTop;
+ if (displayShield) {
+ // If the shield is displayed, we need some extra marginTop so that the bottom of the
+ // main icon is still aligned with the bottom of all the other system icons.
+ int shieldHeightAddition = Math.round(fullBatteryIconHeight - mainBatteryHeight);
+ // However, the other system icons have some embedded bottom padding that the battery
+ // doesn't have, so we shouldn't move the battery icon down by the full amount.
+ // See b/258672854.
+ marginTop = shieldHeightAddition
+ - res.getDimensionPixelSize(R.dimen.status_bar_battery_extra_vertical_spacing);
+ } else {
+ marginTop = 0;
+ }
+
int marginBottom = res.getDimensionPixelSize(R.dimen.battery_margin_bottom);
LinearLayout.LayoutParams scaledLayoutParams = new LinearLayout.LayoutParams(
Math.round(fullBatteryIconWidth),
Math.round(fullBatteryIconHeight));
- scaledLayoutParams.setMargins(0, 0, 0, marginBottom);
+ scaledLayoutParams.setMargins(0, marginTop, 0, marginBottom);
mDrawable.setDisplayShield(displayShield);
mBatteryIconView.setLayoutParams(scaledLayoutParams);