Giter Club home page Giter Club logo

bottomleftmenu's Introduction

Deprecated

An easy to use menu view, located at the bottom left corner of the screen.

Alt text

Required min API level 11

BASIC USAGE

Download

Edit your gradle script to include the library:

dependencies {
        compile 'com.rany.albeg.wein.bottomleftmenu:bottom-left-menu:1.1.4'
}

Add the menu to your XML layout file:

<RelativeLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"

    ...

    <com.rany.albeg.wein.bottomleftmenu.BottomLeftMenu
        android:id="@+id/bottom_left_menu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"

        <!-- Custom attributes ( values are set to default in this example ): -->

        app:blm_itemNormalStateColor="@android:color/transparent"
        app:blm_itemPressedStateColor="#0099cc"
        app:blm_itemTextColor="@android:color/black"
        app:blm_itemTextSize="12sp"
        app:blm_openCloseAnimation="bottom_top" <!-- More options are: left_right and fade_in-->
        app:blm_showDivider="true"
        app:blm_dividerHeight="1dp"
        app:blm_dividerColor="#d3d3d3">

    </com.rany.albeg.wein.bottomleftmenu.BottomLeftMenu>

</RelativeLayout>

Use the menu in java code, like so:

mMenu = (BottomLeftMenu) findViewById(R.id.bottom_left_menu);
/*
 * Populate the menu with views.
 */
mMenu.addMenuItem(R.drawable.ic_action_settings, R.string.settings, _MENU_ID_SETTINGS);
mMenu.addMenuItem(R.drawable.ic_action_about, R.string.about, _MENU_ID_ABOUT);
mMenu.addMenuItem(R.drawable.ic_rating_good, R.string.rate, _MENU_ID_RATE);
mMenu.addMenuItem(R.drawable.ic_action_search, R.string.search, _MENU_ID_SEARCH);
mMenu.addMenuItem(R.drawable.ic_social_share, R.string.share, _MENU_ID_SHARE);
mMenu.addMenuItem(R.drawable.ic_collections_cloud, R.string.upload, _MENU_ID_UPLOAD);
mMenu.addMenuItem(R.drawable.ic_social_send_now, R.string.send, _MENU_ID_SEND);
/*
 * Set a listener for click events.
 */
mMenu.setOnBottomLeftMenuItemClickListener(this);

Handle click events:

@Override
public void onClick(BottomLeftMenuItem item) {
    /*
     * getIdentifier(), not getId()
     */
    int id = item.getIdentifier();

    if (id == _MENU_ID_UPLOAD) {
        /* Upload something */
    }
    else if (id == _MENU_ID_SHARE) {
        /* Share something */
    }
    else if (id == _MENU_ID_SEND) {
        /* Send something */
    }

    // etc...
}

MORE FEATURES

1. Get a reference to each one of the items in the menu, by:

BottomLeftMenuItem item = mMenu.getMenuItemAt(index);
TextView itemText= item.getTextView();
ImageView itemIcon = item.getImageView();

2. Implement your own custom animation for opening and closing the menu:

mMenu.setOpenCloseAnimation(new OpenCloseAnimation(this) {
    
    @Override
    public Animation open() {
        /* Return an Animation object for opening the menu. */
    }
    
    @Override
    public Animation close() {
        /* Return an Animation object for closing the menu. */
    }
});

EXTRA

You might want to override onBackPressed() and onKeyDown(int keyCode, KeyEvent event) for opening and closing the menu:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_MENU) {

        if (mMenu.isOpened())
            mMenu.closeMenu();
        else {
            mMenu.openMenu();
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

@Override
public void onBackPressed() {

    if (mMenu.isOpened()) {
        mMenu.closeMenu();
    } else {
        super.onBackPressed();
    }
}

AUTHOR

Rany Albeg Wein

LICENSE

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.

bottomleftmenu's People

Contributors

ranyalbegwein avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.