AppCompatDrawableManager.get () vs VectorDrawableCompat.create ()

I am using support version 24.2.1 and have included supporting vectors with AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

What is the difference in these functions relative to support vectors? I have used VectorDrawableCompat.create(getResources(), R.drawable.my_vector, null). But this does not output to my test device (Android 4.3) when programmatically programmed like this:

button.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);

The use AppCompatDrawableManager.get().getDrawable(getActivity(), R.drawable.my_vector);(wrapped in a state selector) seems to work fine, although I can't find the documentation for it.

+4
source share
1 answer

What is the difference in these functions relative to support vectors?

AppCompatDrawable.getDrawable(...) will inflate all kinds of drawings, including

  • API 21 ( build script; )
  • AppCompat
  • , ContextCompat.getDrawable(Context, int)

AppCompatDrawableManager.get().getDrawable(Context, int), API. .

VectorDrawableCompat.create(...) ( build script, ).

(Android 4.3)

VectorDrawableCompat.create(...) null . , drawable , , , , , PNG API 21.

API 21, build.gradle:

// Gradle Plugin 2.0+  
android {  
  defaultConfig {  
    vectorDrawables.useSupportLibrary = true  
  }  
}  

. Android Support Library 23.2 .

24.2.1 AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)

. build.gradle, .

, LayerDrawable StateListDrawable.

AppCompat - , , .

+9

Source: https://habr.com/ru/post/1658825/


All Articles