medyo / Fancybuttons

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

Graphic scaling #33

Closed ToddManUtah closed 8 years ago

ToddManUtah commented 9 years ago

Does the library support scaling of graphics?

I have a ImageButtton I'm trying to replace. I have it working with ImageButton with the following:

<ImageButton

    android:id="@+id/app_list_refresh_button"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_margin="5dp"
    android:adjustViewBounds="false"
    android:padding="1dp"
    android:scaleType="fitCenter"
    android:src="@drawable/button_refresh"
    android:background="@color/button_material_dark"/>

The image is 256x256 and I'm trying to have the button scale it down to fit into the FancyButton. But, I can't get it to scale down.

   <mehdi.sakout.fancybuttons.FancyButton
        android:id="@+id/app_list_refresh_button"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:padding="5dp"
        fancy:fb_iconResource="@drawable/button_refresh"
        fancy:fb_fontIconSize="25dp"
        fancy:fb_iconPaddingLeft="0dp"
        fancy:fb_iconPaddingRight="0dp"
        fancy:fb_defaultColor="#696969"
        fancy:fb_focusColor="#a9a9a9"
        fancy:fb_radius="5dp"/>
medyo commented 9 years ago

what do you mean by scaling it ? having same icon size as button ?

ToddManUtah commented 9 years ago

I have a graphic that is 150x150. I want the button to be 30x30. The problem is, that I can't get the graphic to scale within the button. If I make the graphic 30x30, then it works. If I don't, the button ends up being huge.

Does that make sense?

Using the standard button, I was able to set the size of the button and instruct the button to scale the image to fit inside those dimensions. I can't quite figure out how to make the FancyButton do the same thing.

Todd Lawson Business: 801-609-8633 Email: todd.c.lawson@gmail.com

On Tue, Aug 18, 2015 at 4:14 AM, Mehdi Sakout notifications@github.com wrote:

what do you mean by scaling it ? having same icon size as button ?

— Reply to this email directly or view it on GitHub https://github.com/medyo/fancybuttons/issues/33#issuecomment-132156961.

medyo commented 9 years ago

I think you should define a ScaleType for the fancybutton Image like so myfancybutton. getIconImageObject().setScaleType(ScaleType.X); Change X by the suitable one : http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

medyo commented 8 years ago

@ToddManUtah any update on this ?

ToddManUtah commented 8 years ago

I just tried it and still no luck. The graphic isn't scaled down. Here's my code:

    refreshButton = (FancyButton) view.findViewById(R.id.app_list_refresh_button);
    refreshButton.getIconImageObject().setScaleType(ImageView.ScaleType.FIT_CENTER);

I also tried several other scale types. All allowed the button to grow beyond the bounds defined for the button. Here is the button xml:

    <mehdi.sakout.fancybuttons.FancyButton
        android:id="@+id/app_list_refresh_button"
        android:layout_width="25dp"
        android:layout_height="25dp"
        android:padding="5dp"
        fancy:fb_iconResource="@drawable/button_refresh"
        fancy:fb_fontIconSize="25dp"
        fancy:fb_iconPaddingTop="5dp"
        fancy:fb_iconPaddingBottom="5dp"
        fancy:fb_iconPaddingLeft="5dp"
        fancy:fb_iconPaddingRight="5dp"
        fancy:fb_defaultColor="#696969"
        fancy:fb_focusColor="#a9a9a9"
        fancy:fb_radius="5dp"/>

The graphic I'm using is 150x150.

medyo commented 8 years ago

Closing. If you still have the issue please re-open