https://www.viralandroid.com/2016/01/android-custom-horizontal-icons-menu.html
Adding custom horizontal menu in android is tricky part but not much difficult. In this tutorial, I am going to show how to implement custom horizontal icons menu in android application with one of the best and easy ways. For this you not need to have good knowledge of java code.
To add custom icons menu in your android application here I am working with XML code and few java code also. Here I have used Buttons, ImageButtons, TextViews, RelativeLayout and LinearLayout in XML activity layout file and also created a XML drawable file inside res/drawable directory to change the background color of icons/buttons when user click/press the icon.
Related:
Android Custom Vertical Dropdown Icons Menu
Changing Background and Text Color of Android ActionBar Option Menu
Android Spinner Example
Following is the complete necessary XML and Java code of different file.
This is the main XML layout file where I have added text view, button and image buttons inside linear and relative layout.
res/layout/custom_horizontal_icons_menu.xml
In java activity file we are going to control on dropdown button click event to show and hide dropdown menu items when button is click.
src/HorizontalDropDownIconMenu.java
Create a new XML file onclick_press_color.xml in res/drawable of your application project and add the following content to change the background color of dropdown items when users click on dropdown items.
res/drawable/onclick_press_color.xml
And following is the different color value of res/values/colors.xml file.
res/values/colors.xml
Now, run your Android Custom Horizontal Icons Menu application and click the dropdown button which will look like the above screenshot.
Adding custom horizontal menu in android is tricky part but not much difficult. In this tutorial, I am going to show how to implement custom horizontal icons menu in android application with one of the best and easy ways. For this you not need to have good knowledge of java code.
To add custom icons menu in your android application here I am working with XML code and few java code also. Here I have used Buttons, ImageButtons, TextViews, RelativeLayout and LinearLayout in XML activity layout file and also created a XML drawable file inside res/drawable directory to change the background color of icons/buttons when user click/press the icon.
Related:
Android Custom Vertical Dropdown Icons Menu
Changing Background and Text Color of Android ActionBar Option Menu
Android Spinner Example
Android Example: How to Make Custom Horizontal Icons Menu in Android
Following is the complete necessary XML and Java code of different file.
XML Layout File
This is the main XML layout file where I have added text view, button and image buttons inside linear and relative layout.
res/layout/custom_horizontal_icons_menu.xml
Java Activity File
In java activity file we are going to control on dropdown button click event to show and hide dropdown menu items when button is click.
src/HorizontalDropDownIconMenu.java
XML Drawable File
Create a new XML file onclick_press_color.xml in res/drawable of your application project and add the following content to change the background color of dropdown items when users click on dropdown items.
res/drawable/onclick_press_color.xml
And following is the different color value of res/values/colors.xml file.
res/values/colors.xml
Now, run your Android Custom Horizontal Icons Menu application and click the dropdown button which will look like the above screenshot.
Comments
Post a Comment