Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
We all know that we can create so many custom drawables in android but when it comes for a dynamic one we still got the goosebumps. So last week I got stuck in one such issue where I want to show a drawable next to my menu item in navigation drawer.
The drawable was a simple one in which I have to create a circular square and in the center there will be the first character of the menu item text. I know its easier to create an image for them and add it but my menu item is the dynamic one coming from server so it can probably change with some changes on server. I know now you will think to get the image from server and put the image in the server but I don’t think that’s a optimal solution as for this simple work my designer have to create a new image each time something is changed on server.
That is why I took the hard road and creates a dynamic drawable for my need and I can tell you that it was pretty much simpler. So I had to make a view like
I started with creating a Drawable class with name “DrawerIcon.java“. It is responsible to create the icon we just have to pass all the required data to this class’s
Now from the your activity where you have created the navigation drawer you have to call the static method createIcon() and rest it will handle itself.
The LayerDrawable drawer_icon_drawable in defined in drawable folder as
And that is all you will have the required view ready for you.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
The results provided were above our expectations both in deliverability timeline as well as operation. They are a top-notch company with many resources and a company we feel honoured to work with again!
Lee Seward
Founder, Gro-Connect
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.