medyo / Fancybuttons

Icons, Borders, Radius ... for Android buttons
1.77k stars 397 forks source link

Fix issue where fontIcon and button text are not center aligned when button width is match_parent #26

Closed squeeish closed 9 years ago

squeeish commented 9 years ago

My original problem:

<mehdi.sakout.fancybuttons.FancyButton
                android:id="@+id/buttonChangePassword"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingBottom="10dp"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:paddingTop="10dp"
                android:layout_marginBottom="25dp"
                fancy:fb_defaultColor="#FF574E"
                fancy:fb_radius="3dp"
                fancy:fb_text="@string/changePassword"
                fancy:fb_textColor="#FFFFFF"
                fancy:fb_textFont="cg_regular.ttf"
                fancy:fb_fontIconResource="&#xf084;"
                fancy:fb_iconPosition="left"
                />

Setting the layout_width to wrap_content works fine, but match_parent will align the icon to the left and the text to the right of the button.

EDIT: Add screenshot of the button as I see it. Ideally the text + icon should be centered in the button.

Imgur

EDIT2: If fb_iconPosition is top or bottom, text gravity works fine. If fb_iconPosition is right, text gravity defaults to left.

medyo commented 9 years ago

It looks perfect, i'll merge it after doing some tests

squeeish commented 9 years ago

That's great, thanks!