Header Ads

Header ADS

How to use vector drawables in Android API lower 21?

 / Gradle Plugin 2.0+

 android {
   defaultConfig {
     vectorDrawables.useSupportLibrary = true
    }
 }

  1. @Override
        public void onCreate() {
            super.onCreate();
            AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); //if need 
        }
    
  2.  or Drawable Start
    <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="3dp"
    android:drawableStart="@drawable/ic_baseline_swap_vert_24"
    android:background="@drawable/default_btn"
    android:text="Click"
    android:textColor="@android:color/white"
    android:visibility="gone" />

add 
<ImageView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  app:srcCompat="@drawable/ic_add" />    <= this is new

No comments

Theme images by Matt Vince. Powered by Blogger.