material-drawer


Source link: https://github.com/HeinrichReimer/material-drawer

material-drawer

Custom drawer implementation for Material design apps.

Demo

A demo app is available on Google Play:

Screenshots

Fixed items Select profile Custom theme

Dependency

material-drawer is available on jitpack.io

Gradle dependency:

repositories {

  // ...
  maven {
 url 'https://jitpack.io' 
}
 
}
dependencies {

  compile 'com.heinrichreimersoftware:material-drawer:2.3.3' 
}

Get the latest dependency at jitpack.io.

How-To-Use

Step 1: Let your Activity extend DrawerActivity:

public class MainActivity extends DrawerActivity {

}

Step 2: Set your content:

setContentView(R.layout.activity_main);

Step 3: Set a profile:

setProfile(

new DrawerProfile()

  .setRoundedAvatar((BitmapDrawable)getResources().getDrawable(R.drawable.profile_avatar))

  .setBackground(getResources().getDrawable(R.drawable.profile_cover))

  .setName(getString(R.string.profile_name))

  .setDescription(getString(R.string.profile_description))

  .setOnProfileClickListener(new DrawerProfile.OnProfileClickListener() {

@Override

public void onClick(DrawerProfile drawerProfile, long id) {

 Toast.makeText(MainActivity.this, "Clicked profile #" + id, Toast.LENGTH_SHORT).show();

}

  
}
)

);

Step 4: Populate your drawer list:

addItem(

new DrawerItem()

  .setImage(getResources().getDrawable(R.drawable.ic_first_item))

  .setTextPrimary(getString(R.string.title_first_item))

  .setTextSecondary(getString(R.string.description_first_item))

  .setOnItemClickListener(new DrawerItem.OnItemClickListener() {

@Override

public void onClick(DrawerItem drawerItem, long id, int position) {

 Toast.makeText(MainActivity.this, "Clicked first item #" + id, Toast.LENGTH_SHORT).show();

}

  
}
)         );
 addDivider();
 addItem(

new DrawerItem()

  .setImage(getResources().getDrawable(R.drawable.ic_second_item))

  .setTextPrimary(getString(R.string.title_second_item))

  .setOnItemClickListener(new DrawerItem.OnItemClickListener() {

@Override

public void onClick(DrawerItem drawerItem, long id, int position) {

 Toast.makeText(MainActivity.this, "Clicked second item #" + id, Toast.LENGTH_SHORT).show();

}

  
}
)

);

Step 5: Add actionBarStyle to your theme:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
  <item name="colorPrimary">@color/color_primary</item>
  <item name="colorPrimaryDark">@color/color_primary_dark</item>
  <item name="colorAccent">@color/color_accent</item>
  <item name="actionBarStyle">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item> </style>

Step 6 (Optional): Change the drawer theme:

The drawer gets themed based on your selected app theme but you can also modify it.

setDrawerTheme(

new DrawerTheme(this)

  .setBackgroundColorRes(R.color.background)

  .setTextColorPrimaryRes(R.color.primary_text)

  .setTextColorSecondaryRes(R.color.secondary_text)

  .setTextColorPrimaryInverseRes(R.color.primary_text_inverse)

  .setTextColorSecondaryInverseRes(R.color.secondary_text_inverse)

  .setHighlightColorRes(R.color.highlight) );

Step 7 (Optional): Set your own Toolbar:

You can set your own Toolbar as you do with ActionBarActivity.

setSupportActionBar(toolbar);

Pro Tip: Lollipop status bar

Step 1: Make your status bar transparent:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
  <item name="android:windowDrawsSystemBarBackgrounds">true</item>
  <item name="android:statusBarColor">@android:color/transparent</item> </style>

That's it! material-drawer takes care of the rest.

Info: DrawerFrameLayout & DrawerView

Of course you can use DrawerFrameLayout and DrawerView alone too. See the comments in the Java files for further information.

Open source libraries

material-drawer uses the following open source libraries or files:

License

Copyright 2015 Heinrich Reimer  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

Truth is a testing framework designed to make your tests and their error messages more readable and discoverable, while being extensible to new types of objects.

Truth adopts a fluent style for test propositions, is extensible in several ways, supports IDE completion/discovery of available propositions, and supports different responses to un-true propositions. Truth can be used to declare JUnit-style assumptions (which skip the test on failure), assertions (interrupt the test on failure), and expectations (continue the test, but collect errors and report failure at the end).

Use gradle tasks to run specific adb commands. You can use this plugin to do things such as:

  • Find all devices attached and get basic info about them
  • Select the first one that complies with a custom rule
  • Install a specific APK from the available build types + flavours
  • Clear preferences or do something related to the APK to prepare for tests
  • Run monkey for that specific APK on that specific device
  • Uninstall the APK

Bash script that exports content provider's data to raw and CSV format. It can be your own content provider or any other provider that android decided not to block with permissions.

Android Studio Support for Additional File Types (CSS & JavaScript).

Current File Types Added:

  • CSS ( Cascading Style Sheet )
  • JavaScript

This plugin help you to set material design icons to your Android project.

Small Android library for use the Interactor (use case) and Executor for running code on a ThreadPool Thread or UI Thread. Normally this library is used for implement the Clean Architecture.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes