AppCompat 23.3 Support Vectors no longer work?

前端 未结 3 764
日久生厌
日久生厌 2020-12-02 09:00

I was using the support vector drawables added in Support Library 23.2 along with AppCompat. I was using vector drawables both with app:srcCompat and inside a <

3条回答
  •  一整个雨季
    2020-12-02 09:35

    To use vectors as compoundDrawables ( ex. for textview ) without using

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    

    which leads to documented high memory usage, just inflate the vector using

    Drawable drawable = AppCompatResources.getDrawable( getContext(), R.drawable.vector_resID );
    if( drawable != null ) drawable.setBounds( 0, 0, iconSize, iconSize );
    TextViewCompat.setCompoundDrawablesRelative( textView, null, null, drawable, null);
    

    This is the way the navDrawer works

提交回复
热议问题