Raiv
Raiv

Reputation: 5781

TextView height dependence on font size with wrap_content parameter

During layout makeup, I often need pixel-to-pixel equivalence with templates. And with TextView, I have a trouble. It has strange vertical size - it equals to font size with some padding above and beyond - from 1 to 4 dp, I suppose. It is different with different font sizes and styles, and even worse, unpredictably different. Is there any way to disable such padding at all? padding in textView

code example :

  <LinearLayout
                android:id="@+id/llCardData"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <!-- android:background="@drawable/red_frame_animation" -->

                <TextView
                    android:id="@+id/tvCardNameLabel"
                    style="@style/LabelDefaultText"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/ncn_name" />

                <TextView
                    android:id="@+id/tvCardCustomName"
                    android:layout_marginTop="3dp"
                    style="@style/PropertyDefaultText"
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:background="@color/panel_background"
                    android:gravity="left|center_vertical"
                    android:paddingLeft="8dp" />
            </LinearLayout>

Upper TextView has font size 16 dp, but occupies about 20-22dp

Upvotes: 2

Views: 895

Answers (1)

Pavel
Pavel

Reputation: 21

try android:includeFontPadding="false" in your TextViews

Upvotes: 2

Related Questions