paparazzi icon indicating copy to clipboard operation
paparazzi copied to clipboard

Attribute "lineHeight" is not handled as part of a style passed through "textAppearance" attribute into TextView

Open amakovskyi opened this issue 5 months ago • 0 comments

Description Attribute lineHeight is not handled when passed as part of textAppearance attribute of TextView.

values.xml

<resources xmlns:tools="http://schemas.android.com/tools">
  <style name="LineHeightStyledText">
    <item name="android:textColor">#f00</item>
    <item name="lineHeight">48sp</item>
  </style>
</resources>

sample_layout_text_appearance.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

  <TextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="32dp"
      android:textSize="24sp"
      android:textAppearance="@style/LineHeightStyledText"
      android:text="@string/some_string"/>

</LinearLayout>

LineHeightTest.kt

class LineHeightTest {

  @get:Rule
  open val paparazzi = Paparazzi(
    deviceConfig = DeviceConfig.NEXUS_5,
    theme = "Theme.PaparazziTestProject",
  )

  @Test
  fun textAppearance() {
    val v = paparazzi.inflate<View>(R.layout.sample_layout_text_appearance)
    paparazzi.snapshot(v)
  }

}

Result (paparazzi screenshot):

Line height attribute is NOT applied, while Android Studio preview and real device applies it.

Android Studio Preview:

Device screenshot:

For comparison, paparazzi render lineHeight if passed as style or as attributes directly in layout:

<TextView
      style="@style/LineHeightStyledText"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="32dp"
      android:textSize="24sp"
      android:text="@string/some_string"/>
<TextView
      
android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="32dp"
      android:textSize="24sp"
      android:textColor="#f00"
      app:lineHeight="48sp"
      android:text="@string/some_string"/>

Result (paparazzi screenshot):

Steps to Reproduce

PaparazziTestProject.zip

Run test LineHeightTest and check report.

Expected behavior

liheHeight attribute should be applied when passed as part of text style through textAppearance attribute.

Additional information:

  • Paparazzi Version: 1.3.4
  • OS: MacOS 14.6.0
  • Compile SDK: 34
  • Gradle Version: 8.7
  • Android Gradle Plugin Version: 8.6.0

amakovskyi avatar Sep 17 '24 19:09 amakovskyi