Closed mariotaku closed 9 years ago
Can you attach some captures or past your code ? so i can reproduce the issue. thanks
just try add layout_margin to its xml attributes, you will find it won't work. maybe this should be removed?
Same sample buttons have already layout_margin and it works perfectly. https://github.com/medyo/fancybuttons/blob/master/samples/src/main/res/layout/activity_xml_buttons.xml#L27
I tried put it in FrameLayout, all layout params except width and height are invalid, I found LayoutParams was always set to LinearLayout.LayoutParams despite of what parent is.
Please paste the code you have tried, so i can reproduce the same scenario.
I can't reproduce it on a new project, but when I put fancybutton in an xml file, and inflate it runtime, It crashes. Actually after I commenting setLayoutParams
out, sample code still works fine: https://github.com/mariotaku/fancybuttons
java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to com.wefika.flowlayout.FlowLayout$LayoutParams
at com.wefika.flowlayout.FlowLayout.onMeasure(FlowLayout.java:239)
at android.view.View.measure(View.java:17547)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17547)
at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1260)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.widget.ScrollView.onMeasure(ScrollView.java:337)
at android.view.View.measure(View.java:17547)
I've tried to run the same sample using FlowLayout Library and it works perfectly. here is my code :
<?xml version="1.0" encoding="utf-8"?>
<merge>
<com.wefika.flowlayout.FlowLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fancy="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start|top"
android:padding="10dp">
<mehdi.sakout.fancybuttons.FancyButton
android:id="@+id/btn_facebook_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:padding="10dp"
fancy:borderColor="#FFFFFF"
fancy:borderWidth="1dp"
fancy:defaultColor="#3b5998"
fancy:focusColor="#5577bd"
fancy:fontIconResource="@string/icon_like"
fancy:fontIconSize="10sp"
fancy:iconPosition="right"
fancy:radius="30dp"
fancy:text="Like my facebook page"
fancy:textColor="#FFFFFF"/>
<Button
android:layout_width="wrap_content"
android:layout_height="100dp"
android:text="dolor" />
</com.wefika.flowlayout.FlowLayout>
</merge>
Does this commit https://github.com/medyo/fancybuttons/pull/26 fixes your issue ?
hi @mariotaku Have you fixed the issue ?
@medyo I use shaped drawable for now because I can't figure out why margin is ignored. Thank you though!
https://github.com/medyo/fancybuttons/blob/master/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java#L406
This causes fancybuttons layout incorrect in layouts other than LinearLayout.