1. KracsNZ's Avatar
    Hi guys,

    Teaching myself Android JAVA but am struggling with an issue that's affecting only one major version of Android, which appears to be all of 5.

    I have an app using SupportFragments with the v4 support library (also tried it with framework fragments using v13 support library). On two of the fragments I have a ScrollView containing a large set of custom buttons. Both of these screen have an issue where the setColorFilter is being ignored when the scroll position is at the very top of the ScrollView. Oddly, if I scroll even 1 pixel the setColorFilter is working. Baffling.

    Note, this only affects Android 5. Android 4, and Android 6 work perfectly. Only the various flavors of 5 I've tested with so far have this problem (5.1.1 - Cyanogen S4, and 5.0.2 - Galaxy Tab S2). The Nexus 9 (6.0), Galaxy Tab 2 (4.2.2) and Galaxy Tab 3 (4.4.2) all work fine.

    Below is the example of the the scroll being at the top of the scrollview, and then scrolling by just a tiny margin showing the color filter applied.

    Issue with setColorFilter on button background (Android 5)-screenshot_2015-10-16-16-14-12.jpg
    Issue with setColorFilter on button background (Android 5)-screenshot_2015-10-16-16-14-32.jpg

    The buttons are initially added in the populate method called from the Fragments onCreateView using:

    PasswordButton<Password> btn = (PasswordButton<Password>)inflater.inflate(R.layout.password_button, viewGroup, false);
    The setObject(password) actually sets a password object to the button, and applies the color filter that it inherits from it's password group to the background using the following code (again all from the onCreateView):

    public void setColour() {
    		int colour = ((ButtonInterface)this.object).getColour();
    		Drawable background = ContextCompat.getDrawable(getContext(), R.drawable.password_button_selector);
    		background.setColorFilter(new PorterDuffColorFilter(colour, PorterDuff.Mode.MULTIPLY));
    The button's style is a made up of a 9patch background (which is where I'm applying the color filter), a small arrow image, and the text.

    I've made a workaround by overriding the onDraw completely for Android 5, and all other variants simply calling super(canvas), but it would be nice to not have to do this as if I start skinning the buttons my custom onDraw will need constant updating.

    The searching I've done found allot of issues the other way (i.e. 5 working, but 4 not), and the ones I've found that had issues with 5 I'm already using the methods they say got it working.

    Any help would be appreciated
    10-17-2015 02:17 AM

Similar Threads

  1. Why viber goes offline on samsung j5?
    By AC Question in forum Ask a Question
    Replies: 6
    Last Post: 11-19-2015, 07:29 AM
  2. Replies: 0
    Last Post: 10-17-2015, 02:10 AM
  3. Can't install apk files on android lollipop v5.1
    By AC Question in forum Ask a Question
    Replies: 1
    Last Post: 10-17-2015, 02:01 AM
  4. Replies: 1
    Last Post: 10-17-2015, 01:58 AM
  5. How to erase words suggested on lg
    By AC Question in forum Ask a Question
    Replies: 1
    Last Post: 10-16-2015, 11:56 PM