Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a navigation drawer without support library

I'm working on a Android project that only support API level > 14. As a consequence, we don't use the Android Support Library.

I would like to use the navigation drawer with the newer API, but all the documentation I found is about how to create navigation drawer using the support library.

How can I create a Activity with a navigation drawer using only the Android SDK with API level > 14?

like image 797
Pierre-Jean Avatar asked Mar 10 '14 13:03

Pierre-Jean


3 Answers

You simply use the support library as it contains the functionality you need. It does not matter that you do not want to use the other functionality contained within the library. It does contain the sliding menu that you want to use so just use it.

The alternative is to write your own code or use a different library.

Try not to think of the support library as "only for backwards compatibility". It provides functionality that is not included in the standard SDK's (such as ViewPager and SlidingDrawer)

like image 107
Kuffs Avatar answered Nov 10 '22 05:11

Kuffs


From the looks of it, the ONLY DrawerLayout implementation comes from the SupportLib (ie. there is not another source of this code).

Also, from the looks of it, it was introduced in API 19, so your API 14 min wouldn't be adequate anyway.

Bottom line, you should just include the SupportLibrary, and move on with your life, there is no significant issue including this library, and it will be much more work to try and create a workaround.

like image 3
Booger Avatar answered Nov 10 '22 06:11

Booger


You can either extract it from the support library v4 source code or use 3rd party library like SlidingMenu

There once was an alternative/official implementation called SlidingDrawer, however it is deprecated since API Level 17.

This is not hard to understand, there are many fancy features which is not contained in the official SDK release. Just go for what you want and don't pay too much attention to where it is from.

like image 2
Robin Avatar answered Nov 10 '22 05:11

Robin