Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Setting LineHeight using dp instead of sp breaks vertical spacing #86

Open
malinajirka opened this issue Dec 30, 2021 · 0 comments
Open

Comments

@malinajirka
Copy link

When I

  • set lineHeight to 44dp to for example Headline3 style
  • update the headline 3 text so it is longer then one line here

The vertical spacing completely breaks - there is a huge (cca 1000dp) line spacing instead of 44dp. Using sp instead of dp fixes the issue.

Patch

Index: sample/src/main/java/com/google/android/material/composethemeadapter/sample/MaterialIntegration.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/sample/src/main/java/com/google/android/material/composethemeadapter/sample/MaterialIntegration.kt b/sample/src/main/java/com/google/android/material/composethemeadapter/sample/MaterialIntegration.kt
--- a/sample/src/main/java/com/google/android/material/composethemeadapter/sample/MaterialIntegration.kt	(revision 2f8d91620d72d4c7ff464edeb094d04d246b4270)
+++ b/sample/src/main/java/com/google/android/material/composethemeadapter/sample/MaterialIntegration.kt	(date 1640865711026)
@@ -130,7 +130,7 @@
                 style = MaterialTheme.typography.h2
             )
             Text(
-                text = "Headline 3",
+                text = "Headline 3 LONG HEADLINE",
                 style = MaterialTheme.typography.h3
             )
             Text(
Index: sample/src/main/res/values/type.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/sample/src/main/res/values/type.xml b/sample/src/main/res/values/type.xml
--- a/sample/src/main/res/values/type.xml	(revision 2f8d91620d72d4c7ff464edeb094d04d246b4270)
+++ b/sample/src/main/res/values/type.xml	(date 1640865736222)
@@ -19,6 +19,7 @@
     <style name="TextAppearance.Sample.Headline3"
         parent="TextAppearance.MaterialComponents.Headline3">
         <item name="fontFamily">@font/dancingscript</item>
+        <item name="lineHeight">44dp</item>
     </style>
 
     <!-- Use TextAppearance.AppCompat.Subhead as parent to avoid inheriting letterSpacing -->

@malinajirka malinajirka changed the title Setting LineHeight using dp instead of sp breaks spacing Setting LineHeight using dp instead of sp breaks vertical spacing Dec 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant