In this tutorial I will guide you on How to import Vector Assets and Drawables in your Android application.
I will also cover how to give support for devices which do not support vector assets using AppCompat library.
Importing Vector Asset using Android Studio
In case of Vector Assets You do not directly copy paste your icons and images in drawable folder.
There is tool in Android Studio for importing Vector Assest or Scalable Vector Graphics (SVG).
Go to File => New => and select Vector Asset.
Importing Vector Assets (SVG) Android Studio
You can also enable RTL (Right to Left) support. When your
application will be running in RTL mode, your SVG icon will be flipped
automatically.
After this step SVG file which you imported above will be converted into XML file.
Vector Drawable XML Preview
At this step we are ready to use above icon in our application but there is a lot more to do.
Backward Compatibility for SVG
Vector Drawables or Scalable Vector Graphics (SVG) were introduced in Android 5.0 (API Level 21).
If your application support devices lower than API Level 21 still you
can use Vector Drawables on devices lower than API Level 21 using
AppCompat Library.
Because AppCompat Library suport Android 2.1 (API Level 7+).
For Fragment Reload // Reload current fragment Fragment frg = null ; frg = getSupportFragmentManager (). findFragmentByTag ( "Your_Fragment_TAG" ); final FragmentTransaction ft = getSupportFragmentManager (). beginTransaction (); ft . detach ( frg ); ft . attach ( frg ); ft . commit (); Your_Fragment_TAG is the name you gave your fragment when you created it This code is for support library. If you're not supporting older devices, just use getFragmentManager instead of getSupportFragmentManager For Activity Reload Intent i = new Intent(MainActivity.this, MainActivity.class); finish(); overridePendingTransition(0, 0); startActivity(i); overridePendingTransition(0, 0); In the above code, we have used overridePendingTransition(), it is used to remove activity create animation while re-creating activity.
Does your application contain a Drawer ? Do you want to have it up and running in less than 5 minutes ? Do you want your drawer to follow the Android Design Guidelines ? Do you have profiles ? Do you need flexibility ? Is Google's navigation Drawer of the design support not enough for you? Do you want a simple and easy to understand api? If any (or all) of these questions seem familiar, the MaterialDrawer is the perfect library for you all. Never waste your time again. It provides you with the easiest possible implementation of a navigation drawer for your application. There is a Header with profiles ( AccountHeader ), a MiniDrawer for Tablets (like Gmail), provide custom DrawerItems , custom colors , custom themes , ... No limits for customizations. A quick overview of what's in it the easiest possible integration integrate in less than 5 minutes uses the androidX support libraries compatible down to API Level 14 includes an AccountSwitcher quick and simpl...
Android Splash Screen is the first screen visible to the user when the application’s launched. Splash screen is one of the most vital screens in the application since it’s the user’s first experience with the application. Splash screens are used to display some animations (typically of the application logo) and illustrations while some data for the next screens are fetched. Typically, the Activity that has the following intent filter set in the AndroidManifest.xml file is the Splash Activity. < intent-filter > < action android:name = "android.intent.action.MAIN" /> < category android:name = "android.intent.category.LAUNCHER" /> </ intent-filter > Android Splash Screen Example Project Structure There are few ways to create the initial screen i.e. Splash Screen of the application. Let’s see each of them. Splash Screen Classical Approach SplashActivity.java import android.content.I...
Comments
Post a Comment