https://www.viralandroid.com/2016/01/android-custom-vertical-dropdown-icons-menu.html
In this tutorial, I am going to show how to create custom vertical dropdown icon menu in android programmatically. Creating and implementing custom menu is not so difficult in android because we can make such menu with XML and to make perfectly working we have to add little bit java code in our app activity file.
We can create and implement drop down icons menu in android only using one XML layout file and a java activity file. But to add some extra effect like animation, hover color, etc. we have to create some XML file in drawable folder or you can add some code in java activity file.
Here, you will learn not only to implement drop down custom icon menu in your android application but also learn to add onClick event to the icon and to add on press or focus color to the icon background.
Related:
Android Dropdown Menu Example
Android Spinner Example
Android Action Bar Tutorial and Example With Option Menu
Let’s start step by step implementing dropdown icon menu in android application. Following are the different XML and java file.
Following is the XML layout file where I have added ImageButton and TextView inside LinearLayout and RelativeLayout with some important attributes.
res/layout/custom_vertical_dropdown_icon_menu.xml
Following is the modified code of java activity file where I have added onClick event to show and hide dropdown icon menu.
src/VerticalDropDownIconMenu.java
For implementing on pressed color in icon background I have create onclick_press_color.xml file inside res/drawable directory. Following is the content of onclick_press_color.xml file.
res/drawable/onclick_press_color.xml
And following is the colors.xml
res/values/colors.xml
That’s all. Now run your Android Custom Vertical Dropdown Icons Menu application and click dropdown button, which will look like the above screenshot.
In this tutorial, I am going to show how to create custom vertical dropdown icon menu in android programmatically. Creating and implementing custom menu is not so difficult in android because we can make such menu with XML and to make perfectly working we have to add little bit java code in our app activity file.
We can create and implement drop down icons menu in android only using one XML layout file and a java activity file. But to add some extra effect like animation, hover color, etc. we have to create some XML file in drawable folder or you can add some code in java activity file.
Here, you will learn not only to implement drop down custom icon menu in your android application but also learn to add onClick event to the icon and to add on press or focus color to the icon background.
Related:
Android Dropdown Menu Example
Android Spinner Example
Android Action Bar Tutorial and Example With Option Menu
Example: How to Implement Custom Vertical Dropdown Icons Menu in Android
Let’s start step by step implementing dropdown icon menu in android application. Following are the different XML and java file.
XML Layout File
Following is the XML layout file where I have added ImageButton and TextView inside LinearLayout and RelativeLayout with some important attributes.
res/layout/custom_vertical_dropdown_icon_menu.xml
Java Activity File
Following is the modified code of java activity file where I have added onClick event to show and hide dropdown icon menu.
src/VerticalDropDownIconMenu.java
For implementing on pressed color in icon background I have create onclick_press_color.xml file inside res/drawable directory. Following is the content of onclick_press_color.xml file.
res/drawable/onclick_press_color.xml
And following is the colors.xml
res/values/colors.xml
That’s all. Now run your Android Custom Vertical Dropdown Icons Menu application and click dropdown button, which will look like the above screenshot.
Comments
Post a Comment