Reputation: 17
I've currently been looking into the navigation drawer of android and see the example code from android they use.
When starting a new project and selecting the navigation drawer activity. It gives basic structure which is great.
From this I see the icons used in the navigation drawer are android default. I wanted to see if possible to add my own png for icons. So far my code (in activity_main_drawer) is
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_connect"
android:icon="@drawable/icon_menu_connect_24"
android:title="Connect" />
<item
android:id="@+id/nav_settings"
android:icon="@drawable/icon_menu_settings_24"
android:title="Settings" />
<item
android:id="@+id/nav_help"
android:icon="@drawable/icon_menu_help_24"
android:title="Help" />
</group>
the _24 at the end of the name is just the 24pixel size indication.
Now after running this code all i get appear in my navigation drawer is square blocks and not the image.
Reason for using own png rather than android default, is looking at the defaults there was no images indicating what i wanted.
Appollogies if question has been posted before and thanks in advance
Upvotes: 0
Views: 310
Reputation: 17
I have found the issue. I found that the image used in the menus need to have a transparent background. The images I was using did not get saved in that format and thus showed as a grey block. So although it gave a preview in the left hand margin in the XML file, it still was not in the right format
Using image asset to generate the icons was more efficient than lots of .PNG files
Upvotes: 0