ceryle / SegmentedButton

Segmented Control with animation for Android API 12+
Apache License 2.0
364 stars 97 forks source link

API 28, Android 9 #38

Open AyupovIlgam opened 5 years ago

AyupovIlgam commented 5 years ago

Hi! Thanx a lot for your awesome library. I'm using pretty old version of it: implementation "com.github.ceryle:SegmentedButton:v1.1.3"

The app crashes on Android 9, API level 28. Logs:

Fatal Exception: java.lang.IllegalArgumentExceptionInvalid Region.Op - only INTERSECT and DIFFERENCE are allowed Raw Text

  | android.graphics.Canvas.checkValidClipOp (Canvas.java:779)   | android.graphics.Canvas.clipPath (Canvas.java:1007)   | co.ceryle.segmentedbutton.RoundedCornerLayout.dispatchDraw (RoundedCornerLayout.java:82)   | android.view.View.buildDrawingCacheImpl (View.java:19472)   | android.view.View.buildDrawingCache (View.java:19338)   | android.view.View.draw (View.java:19927)   | android.view.ViewGroup.drawChild (ViewGroup.java:4333)   | android.view.ViewGroup.dispatchDraw (ViewGroup.java:4112)   | android.view.View.updateDisplayListIfDirty (View.java:19073)   | android.view.View.draw (View.java:19935)   | android.view.ViewGroup.drawChild (ViewGroup.java:4333)   | android.view.ViewGroup.dispatchDraw (ViewGroup.java:4112)   | co.ceryle.segmentedbutton.SegmentedButtonGroup.dispatchDraw (SegmentedButtonGroup.java:193)   | android.view.View.updateDisplayListIfDirty (View.java:19073)   | android.view.View.draw (View.java:19935)   | android.view.ViewGroup.drawChild (ViewGroup.java:4333)   | android.view.ViewGroup.dispatchDraw (ViewGroup.java:4112)   | android.view.View.draw (View.java:20210)   | android.view.View.updateDisplayListIfDirty (View.java:19082)   | android.view.View.draw (View.java:19935)   | android.view.ViewGroup.drawChild (ViewGroup.java:4333)   | android.view.ViewGroup.dispatchDraw (ViewGroup.java:4112)   | android.view.View.updateDisplayListIfDirty (View.java:19073)   | android.view.View.draw (View.java:19935)   | android.view.ViewGroup.drawChild (ViewGroup.java:4333)   | android.view.ViewGroup.dispatchDraw (ViewGroup.java:4112)   | android.view.View.draw (View.java:20210)   | android.widget.ScrollView.draw (ScrollView.java:1739)   | android.view.View.updateDisplayListIfDirty (View.java:19082)   | android.view.View.draw (View.java:19935)   | android.view.ViewGroup.drawChild (ViewGroup.java:4333)   | android.view.ViewGroup.dispatchDraw (ViewGroup.java:4112)   | android.view.View.draw (View.java:20210)   | android.view.View.updateDisplayListIfDirty (View.java:19082)   | android.view.View.draw (View.java:19935)   | android.view.ViewGroup.drawChild (ViewGroup.java:4333)   | android.view.ViewGroup.dispatchDraw (ViewGroup.java:4112)   | android.view.View.updateDisplayListIfDirty (View.java:19073)   | android.view.View.draw (View.java:19935)   | android.view.ViewGroup.drawChild (ViewGroup.java:4333)   | android.view.ViewGroup.dispatchDraw (ViewGroup.java:4112)   | android.view.View.updateDisplayListIfDirty (View.java:19073)   | android.view.View.draw (View.java:19935)   | android.view.ViewGroup.drawChild (ViewGroup.java:4333)   | android.view.ViewGroup.dispatchDraw (ViewGroup.java:4112)   | android.view.View.updateDisplayListIfDirty (View.java:19073)   | android.view.View.draw (View.java:19935)   | android.view.ViewGroup.drawChild (ViewGroup.java:4333)   | android.view.ViewGroup.dispatchDraw (ViewGroup.java:4112)   | android.view.View.updateDisplayListIfDirty (View.java:19073)   | android.view.View.draw (View.java:19935)   | android.view.ViewGroup.drawChild (ViewGroup.java:4333)   | android.view.ViewGroup.dispatchDraw (ViewGroup.java:4112)   | android.view.View.draw (View.java:20210)   | com.android.internal.policy.DecorView.draw (DecorView.java:780)   | android.view.View.updateDisplayListIfDirty (View.java:19082)   | android.view.ThreadedRenderer.updateViewTreeDisplayList (ThreadedRenderer.java:686)   | android.view.ThreadedRenderer.updateRootDisplayList (ThreadedRenderer.java:692)   | android.view.ThreadedRenderer.draw (ThreadedRenderer.java:801)   | android.view.ViewRootImpl.draw (ViewRootImpl.java:3312)   | android.view.ViewRootImpl.performDraw (ViewRootImpl.java:3116)   | android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2485)   | android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1460)   | android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7184)   | android.view.Choreographer$CallbackRecord.run (Choreographer.java:949)   | android.view.Choreographer.doCallbacks (Choreographer.java:761)   | android.view.Choreographer.doFrame (Choreographer.java:696)   | android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:935)   | android.os.Handler.handleCallback (Handler.java:873)   | android.os.Handler.dispatchMessage (Handler.java:99)   | android.os.Looper.loop (Looper.java:193)   | android.app.ActivityThread.main (ActivityThread.java:6669)   | java.lang.reflect.Method.invoke (Method.java)   | com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)   | com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)

I've already tried to upgrade library to version v2.0.2, but some methods appeared not to work. E.g. setOnClickedButtonPosition. Could you please update wiki or somehow help me to fix this bug?

yarodevuci commented 5 years ago

error: attribute sbg_selectorTextColor (aka com.securedchat.me:sbg_selectorTextColor) not found @ceryle please help...

dejiapps commented 5 years ago

I'm having a similar issue.

yarodevuci commented 5 years ago

@dejiapps I had to remove this framework ...

AyupovIlgam commented 5 years ago

@yarodevuci @dejiapps so did I

addisonElliott commented 5 years ago

I had this same issue until I realized that I had an outdated version.

This is resolved in the latest version so my suggestion is to upgrade to v2.0.2.

The reason you know that this is outdated is because of the line: | co.ceryle.segmentedbutton.RoundedCornerLayout.dispatchDraw (RoundedCornerLayout.java:82) That file doesn't exist in the repository anymore.

addisonElliott commented 5 years ago

I've forked this library and did a major rehaul on the code. My library can be found at the link below. I hope to keep it up-to-date and maintained.

I hope you guys find it useful and if so, please star it.

https://github.com/addisonElliott/SegmentedButton

rital-naik-adrosonic commented 4 years ago

Hi team, I thin Error:(13) error: attribute sbg_selectorTextColor' not found. #29 and this issue is connected

even after trying out both the alternatives, I am not able to run the project

addisonElliott commented 4 years ago

Did you try the first answer's solution?

@burkaslarry seems it has been renamed. "app:sb_textColor_onSelection="@color/white"" works for me.

rital-naik-adrosonic commented 4 years ago

In my xml layout:

                <co.ceryle.segmentedbutton.SegmentedButtonGroup
                    android:id="@+id/tab_layout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    app:sbg_animateSelector="cycle"
                    app:sbg_animateSelectorDuration="250"
                    app:sbg_backgroundColor="@color/white"
                    app:sbg_dividerColor="@color/colorDivider"
                    app:sbg_dividerPadding="10dp"
                    app:sbg_dividerRadius="10dp"
                    app:sbg_dividerSize="1dp"
                    app:sbg_position="1"
                    app:sbg_radius="2dp"
                    app:sbg_ripple="true"
                    app:sbg_rippleColor="@color/colorLightBG"
                    app:sbg_selectorColor="@color/colorAccent">
                    <!--                        app:sbg_selectorTextColor="@color/white"-->
                    <!--android:background="@drawable/button_background"-->

                    <co.ceryle.segmentedbutton.SegmentedButton
                        android:id="@+id/tab_buy"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:minHeight="10dp"
                        android:text="BFX Buy"
                        android:textColor="@color/colorPrimary"
                        app:sb_textColor_onSelection="@color/white" />
                    <!--                            app:sb_selectedTextColor="@color/white"-->
                    <co.ceryle.segmentedbutton.SegmentedButton
                        android:id="@+id/tab_sell"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:layout_height="match_parent"
                        android:minHeight="10dp"
                        android:text="BFX Sell"
                        android:textColor="@color/colorPrimary"
                        app:sb_textColor_onSelection="@color/white" />
                    <!--                            app:sb_selectedTextColor="@color/white"-->
                </co.ceryle.segmentedbutton.SegmentedButtonGroup>

in fragment. java file

    mTabLayout.setOnPositionChangedListener(new SegmentedButtonGroup.OnPositionChangedListener() {
        @Override
        public void onPositionChanged(int position) {
            mPresenter.setOrderType(position);
            amount.setText("");
            placeOrder.setVisibility(View.GONE);
            mLayoutResult.setVisibility(View.GONE);
            updateAmountHint(position);
        }
    });

in app level gradle dependency implementation 'com.github.ceryle:SegmentedButton:v2.0.2'

However UI device-2019-12-03-120104

addisonElliott commented 4 years ago

Oh okay, it sounds like you solved the first problem and another came up. This project has not been worked on in some time, and it's unlikely for a PR/fixes to happen.

I made a new project that has similar functionality at https://github.com/addisonElliott/SegmentedButton

You can try that out and see if that will help your problem. If you post an issue on that project (with the corresponding code), I'll help you fix a problem if you have any.

rital-naik-adrosonic commented 4 years ago

Hello guys, Sorry for late reply. This issue has been resolved. The reason for UI being not rendering properly was, the wrong set of properties I'd been using. Following code solved my issue:

                <co.ceryle.segmentedbutton.SegmentedButtonGroup
                    android:id="@+id/tab_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:sbg_animateSelector="cycle"
                    app:sbg_animateSelectorDuration="250"
                    app:sbg_backgroundColor="@color/white"
                    app:sbg_dividerColor="@color/colorDivider"
                    app:sbg_dividerPadding="10dp"
                    app:sbg_dividerRadius="10dp"
                    app:sbg_dividerSize="1dp"
                    app:sbg_position="1"
                    app:sbg_radius="2dp"
                    app:sbg_ripple="true"
                    app:sbg_rippleColor="@color/colorLightBG"
                    app:sbg_selectorColor="@color/colorAccent">

                    <co.ceryle.segmentedbutton.SegmentedButton
                        android:id="@+id/tab_buy"
                        android:layout_weight="1"
                        android:layout_width="0dp"
                        android:layout_height="40dp"
                        android:minHeight="10dp"
                        app:sb_text="BFX Buy"
                        app:sb_textColor="@color/colorAccent"
                        app:sb_textColor_onSelection="@color/white"/>
                    <co.ceryle.segmentedbutton.SegmentedButton
                        android:id="@+id/tab_sell"
                        android:layout_weight="1"
                        android:layout_width="0dp"
                        android:layout_height="40dp"
                        android:minHeight="10dp"
                        app:sb_text="BFX Sell"
                        app:sb_textColor="@color/colorAccent"
                        app:sb_textColor_onSelection="@color/white"/>
                </co.ceryle.segmentedbutton.SegmentedButtonGroup>