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.
The best way to learn is to read and that’s true for a developer as well. If you want to become a better developer, you have to read more code. It’s as simple as that. Books, blogs, forums are all good to a certain extent but there is nothing that can replace some fully-functional, exhaustive open-source projects where the entire app with all its resources is right in front of you. All you have to do is sit back, take a cup of coffee and read some kick-ass code . Here in this article, we bring some of the best open-source Android apps from various categories and genres to fulfill all your learning and development needs. You can try these apps directly from Play Store to have a hands-on experience before diving deep into the code. The difficulty level attached with each app will help you to judge if you should instantly dive into it or put it aside for the time being. LeafPic ( Github | Play Store | Difficulty: Beginner) Photo and video gallery app...
Here i am giving you “ Top 10 Awesome Android Libraries ” t hat are the ones who are interesting to try it out. Without further ado, let’s jump right into our list. We’ll kick off with one of the oldest, and I’d argue, one of the most useful Android libraries. 1. Retrofit Retrofit is type-safe HTTP client that allows you to define your REST API as an interface. You can manipulate the API requests’ body, headers, query parameters and much more via annotations, which makes everything clean and simple. Retrofit also allows synchronous and asynchronous API calls execution. interface ApiService { @GET ( "movie/{id}" ) fun getMovieDetails ( @Path ( "id" ) id : String ) : Call < MovieDetails > } To top it off, Retrofit offers a separate Rx module. If you are using Rx, this module returns your API call as an Observable so you are able to chain it with the rest of your application. These are just a few of the many reasons we at I...
Comments
Post a Comment