TypeValue's getValue returns COMPLEX_RADIX_0p23 instead of a reference

40 views Asked by At

I'm using this code to change a view's background whether if it is a colour or a drawable.

static void backgroundChangerCompat(Resources resources, int rId, View view) {
        TypedValue value = new TypedValue();
        resources.getValue(rId,value,true);
        if(value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
            view.setBackgroundColor(ResourcesCompat.getColor(resources,rId,null));
        }
        else if(value.type == TypedValue.TYPE_REFERENCE) {
            view.setBackground(ResourcesCompat.getDrawable(resources,rId,null));
        }
    }

If I supplied it with a reference i.e a drawable xml, the value resolves to a COMPLEX_RADIX_0p32 which is 0x3. Why is that?

0

There are 0 answers