JoanZapata / android-iconify

Android integration of multiple icon providers such as FontAwesome, Entypo, Typicons,...
http://joanzapata.com/android-iconify
Other
3.93k stars 526 forks source link

Icon is not vertically centered. #115

Closed ladjzero closed 9 years ago

ladjzero commented 9 years ago

Here is my xml snippet

<com.joanzapata.iconify.widget.IconTextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:gravity="center"
    android:text="{md-info 24sp}信息"
    android:textColor="@color/dark_primary"
    android:textSize="18sp"/>

<com.joanzapata.iconify.widget.IconTextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:gravity="center"
    android:text="{md-info 24sp}info"
    android:textColor="@color/dark_primary"
    android:textSize="18sp"/>

The icon and the text aside are not aligned. 20150905_142119_screenshot_zte g717c

Is there anything wrong in my xml?

JoanZapata commented 9 years ago

Nothing wrong, I'll investigate it, thanks for the report.

JoanZapata commented 9 years ago

It's actually a duplicate of #118 which just got fixed.

sourab-sharma commented 7 years ago

In class: com.joanzapata.iconify.internalCustomTypefaceSpan

Method: draw(Canvas canvas, CharSequence text,int start, int end, float x, int top, int y,int bottom, Paint paint)

I made the following change to align "{fa-arrows-h}" in center of two strings. It was baseaglined by default somehow and was not vertically centered in my case.

 canvas.drawText(icon,
                x - TEXT_BOUNDS.left,
                rotate?  y - TEXT_BOUNDS.bottom + TEXT_BOUNDS.height() * baselineRatio:y, paint);