Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

library draw correct only from API 23 and above #47

Closed
bmx666 opened this issue Jan 15, 2017 · 20 comments
Closed

library draw correct only from API 23 and above #47

bmx666 opened this issue Jan 15, 2017 · 20 comments
Assignees
Labels
Milestone

Comments

@bmx666
Copy link
Contributor

bmx666 commented Jan 15, 2017

Screenshots from emulators:

screenshot1
screenshot2
screenshot3
screenshot4

screenshot_api21_0
screenshot_api21_1

@djodjoni djodjoni added the bug label Jan 16, 2017
@djodjoni djodjoni added this to the 1.3.1 milestone Jan 16, 2017
@djodjoni djodjoni self-assigned this Jan 16, 2017
@djodjoni
Copy link
Member

this is an issue with default drawables and the background for the theme on the api16 examples.
Ill push a fix shortly. however you can put your custom drawables and themes as you like

djodjoni added a commit that referenced this issue Jan 17, 2017
fix default range/track drawable for API 21/23 related to #47
@lordgero
Copy link

Hello, I would like to know if you got updates on this issue.
Thanks.

@djodjoni
Copy link
Member

It is partially fixed but didn't gave time to followup. Ill probably wrapup a minor release next week

@joacimfloren
Copy link

Hey, is there any updates on this issue?
Thanks!

@MikeW1986
Copy link

MikeW1986 commented Mar 29, 2017

some news about the update?

@bmx666
Copy link
Contributor Author

bmx666 commented Apr 1, 2017

I use hack for get all drawables correct like in SeekBar:

Helper class for extract Thumb from SeekBar

public class HFAppCompatSeekBar extends AppCompatSeekBar {

    public HFAppCompatSeekBar(Context context) {
        super(context);
    }

    public HFAppCompatSeekBar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public HFAppCompatSeekBar(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public Drawable getThumb() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
            return super.getThumb();

        // Using reflection, don't override setThumb
        // because others methods in AbsSeekBar change mThumb
        try {
            // HFAppCompatSeekBar -> AppCompatSeekBar -> SeekBar -> AbsSeekBar
            Class<?> cls = this.getClass().getSuperclass().getSuperclass().getSuperclass();
            Field f = cls.getDeclaredField("mThumb");
            f.setAccessible(true);
            return (Drawable) f.get(this);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Somewhere in code

mMySeekBar = (MultiSlider) view.findViewById(R.id.myseekbar);
            // HACK: for draw track
            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
                HFAppCompatSeekBar mTempSeekBar = new HFAppCompatSeekBar(ctx);
                mMySeekBar.setTrackDrawable(mTempSeekBar.getProgressDrawable());
            }
            for (int i = 0; i < 2; ++i) {
                HFAppCompatSeekBar mTempSeekBar = new HFAppCompatSeekBar(ctx);
                mMySeekBar.getThumb(i).setThumb(mTempSeekBar.getThumb());
            }
            // HACK: for draw range
            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
                HFAppCompatSeekBar mTempSeekBar = new HFAppCompatSeekBar(ctx);
                mTempSeekBar.setProgress(100);
                mTempSeekBar.refreshDrawableState();
                mMySeekBar.getThumb(1).setRange(mTempSeekBar.getProgressDrawable());
            }

djodjoni added a commit that referenced this issue Apr 3, 2017
@djodjoni
Copy link
Member

djodjoni commented Apr 3, 2017

@bmx666 this works partially as some cases and states are not properly handled .

I have pushed https://github.com/apptik/MultiSlider/tree/issue47
where I did some cleanup and fix most of the issues some time ago.
There is still an issue with api21 with the styles.
I believe related to colorControlActivated and colorControlHighlight.
You can check it out if you have time.
I will also try to solve it but not before the end of the week as I am terribly busy.

@yeray697
Copy link

yeray697 commented Jan 15, 2018

Hi, I'm using 1.3.1-SNAPSHOT, but it's still being drawn as a white line and transparent color when user touches, did I skip some step?

@bmx666
Copy link
Contributor Author

bmx666 commented Jan 15, 2018

Hi @yeray697, can you give more info and share the code?

@bmx666 bmx666 reopened this Jan 15, 2018
@yeray697
Copy link

Sure
I have this on my main style:

    <...
        <item name="multiSliderStyle">@style/Widget.MultiSlider</item>
    .../>
    <style name="Widget.MultiSlider" parent="android:Widget">
        <item name="colorControlActivated">@color/colorPrimaryDark</item>
        <item name="colorControlHighlight">@color/colorPrimaryDark</item>
    </style>

(colorPrimaryDark = green)

@bmx666
Copy link
Contributor Author

bmx666 commented Jan 15, 2018

@yeray697, without colorControlActivated and colorControlHighlight attrs it's work correctly?

@yeray697
Copy link

No, it's still white and transparent. I've also tried without style and I got the same result

@bmx666
Copy link
Contributor Author

bmx666 commented Jan 15, 2018

@yeray697, which API are you use?

@yeray697
Copy link

compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId ""
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 
        versionName ""
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }

@bmx666
Copy link
Contributor Author

bmx666 commented Jan 15, 2018

@yeray697, you have similar issue on all emulators/devices (api 21/22/23/25/26/27) ?

@yeray697
Copy link

It's working on emulator with api 21, but there's another style problem (or I don't know how to change it), when I touch, appears a red transparent circle and I would like to change it.
In api 23 this circle works good, it appears with the color I want

@bmx666
Copy link
Contributor Author

bmx666 commented Jan 16, 2018

@yeray697, checked on API 21, all ok.
You must change colorAccent for change multislider style. For ripple effect see issue #65

@bmx666 bmx666 closed this as completed Jan 16, 2018
@yeray697
Copy link

Hi, sorry for the delay.
On API < 21 it's still show as the first comment of that thread.
screen_19_01_2018_11 03 34
I don't mind if I have to do my own style for < 21, but the main problem is that dots are not drawn.

On the other hand, the ripple effect issue is solved as you said on #65.

@bmx666
Copy link
Contributor Author

bmx666 commented Jan 19, 2018

@yeray697 for API 19 and lower you should use holo style. If you need material style you can use hack with seekbar to get style and apply it to multislider (see my comment above)

@yeray697
Copy link

Nice, thank you, I haven't realized that Holo was neccesary < 19

By the way, I think you have two unused images (or I haven't found where are used): MultiSlider/holo-style/src/main/res/drawable-hdpi/seek_thumb_normal.png and MultiSlider/holo-style/src/main/res/drawable-hdpi/seek_thumb_pressed.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants