Git Product home page Git Product logo

jellytoolbar's Introduction

JellyToolbar

License Yalantis

Android app on Google Play

Check this project on dribbble

Requirements

  • Android SDK 16+

Usage

Add to your root build.gradle:

allprojects {
	repositories {
	  ...
	  maven { url "https://jitpack.io" }
	}
}

Add the dependency:

dependencies {
  compile 'com.github.yalantis:jellytoolbar:v1.0'
}

How to use this library in your project?

First of all, add JellyToolbar to the xml layout of your activity, so it looks like that:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.yalantis.jellytoolbar.widget.JellyToolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingStart="@dimen/activity_horizontal_margin"
        app:cancelIcon="@drawable/ic_close"
        app:endColor="@color/colorEnd"
        app:icon="@drawable/ic_search"
        app:startColor="@color/colorStart"
        app:title="@string/str_news_feed"
        app:titleTextColor="@android:color/white" />

</LinearLayout>

After that pass an instance of the JellyListener and content view (the view which would be inserted to the toolbar) to the JellyToolbar. JellyToolbar has getToolbar() method to let you use all the methods of the standard Toolbar.

public class MainActivity extends AppCompatActivity {

    private JellyToolbar toolbar;
    private AppCompatEditText editText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        toolbar = (JellyToolbar) findViewById(R.id.toolbar);
        toolbar.getToolbar().setNavigationIcon(R.drawable.ic_menu);
        toolbar.setJellyListener(jellyListener);

        editText = (AppCompatEditText) LayoutInflater.from(this).inflate(R.layout.edit_text, null);
        editText.setBackgroundResource(R.color.colorTransparent);
        toolbar.setContentView(editText);
    }

    private JellyListener jellyListener = new JellyListener() {
        @Override
        public void onCancelIconClicked() {
            if (TextUtils.isEmpty(editText.getText())) {
                toolbar.collapse();
            } else {
                editText.getText().clear();
            }
        }
    };

}

To control the animation flow use collapse() and expand() methods.

Override onToolbarExpandingStarted(), onToolbarCollapsingStarted(), onToolbarExpanded() and onToolbarCollapsed() methods of the JellyListener to get all the animation events.

Let us know!

We’d be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding the animation.

P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned!

License

The MIT License (MIT)

Copyright © 2017 Yalantis, https://yalantis.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

jellytoolbar's People

Contributors

igalata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jellytoolbar's Issues

AndroidX not supported

After migrating to AndroidX, JellyToolbar still uses the old android.support.v7.widget.Toolbar
Would be nice to create a new release for AndroidX

don't support contain other view

like this:

            <com.yalantis.jellytoolbar.widget.JellyToolbar
                android:id="@+id/toolbar_main"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:cancelIcon="@android:drawable/ic_menu_close_clear_cancel"
                app:icon="@android:drawable/ic_menu_search">
                <Spinner
                    android:id="@+id/spinner_nav"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:clipToPadding="false"/>
            </com.yalantis.jellytoolbar.widget.JellyToolbar>

Bug on demo: not handling keyboard and back button correctly

clicking on the search action item should trigger the keyboard because it should allow us to start typing.

The X should be shown only when there is text being written, and we should have an arrow to close the search, which should also close the keyboard.
Instead, what I see is a single X button that clears the query and only then closes, but even when it closes, it doesn't close the keyboard.

Not only that, but when clicking the back button, it closes the activity even if there is still text written. When we are editing the text, and then click on the back button, it should either close the keyboard , or close the editing (or both, as done on the play store).

Change demo GIF to Android

The gif demo runs on an iPhone while JettyToolbar is for Android..
What tool have you used to generate the GIF?

Not working with RTL

LTR
screenshot_20170627-170646

RTL
screenshot_20170627-163714

As you can see the search icon is missing all together, the filter icon that was just to the left of the search icon is aligned to the left and the JellyView is bigger and located to the right with visible X and hiding the navigation menu button

Is there a fix for that?

Thank you

Completely misaligned

Following the demo (Literally copying and pasting but just changing some colors) the Toolbar presents a total misalignation. Tested in API 26, 25, 24, 23, 22, 21 and 19 and not working in any of them.

captura de pantalla 2017-07-03 a la s 18 19 43

cannot set Alignment of the components

Cannot set the alignment properly with default config.
For Icons too alignment cannot set.
searchissue

EditText is not getting aligned properly and also the height of the bar set manually it crops the layout from below instead of adjusting.

Please guide.

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.