Giter VIP home page Giter VIP logo

reveallayout's Introduction

RevealLayout(Google Play)

Build Status
A layout which can make some reveal animation which is introduced in material design guideline.

Overview

  • Support single item in layout to show/hide it
  • Support multiple item in layout to show item one by one
  • Support use it as fragment root layout to make fragment transation animation, even I think in a really dirty way :(
  • Support api 10+ devices(should be lower, but I haven't test it), suggest to use it on api 18+ devices for hardware acceleration support http://developer.android.com/guide/topics/graphics/hardware-accel.html#unsupported

Video

Sample Video

Goolge Play Demo

Get it on Google Play

Changelog

  • 1.0.2: remove nineoldandroids, support fragment back animation, update demo appcompat version, support animation callback.
  • 1.0.1: make api level lower
  • 1.0.0: release

reveallayout's People

Contributors

angeldevil avatar imidhuntv avatar kyze8439690 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

reveallayout's Issues

Reveal Circle animation doesn't work even on API18+

So I followed every step provided by the answer on: http://stackoverflow.com/questions/31624935/floatingactionbutton-expand-into-a-new-activity

And imported everything except MainActivity, MultiChildActivity, SingleChildActivity and FragmentSampleActivity.

Here's my MainActivity.java

public class Home extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {
    CoordinatorLayout homeLayout;

    private GoogleApiClient client;
    private Toolbar toolbar;
    private TabLayout tabLayout;
    private ViewPager viewPager;
    private RevealLayout mRevealLayout;



    View mViewToReveal;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        homeLayout = (CoordinatorLayout) findViewById(R.id.CoordinatorLayout);
        setSupportActionBar(toolbar);

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        viewPager = (ViewPager) findViewById(R.id.viewpager);
        setupViewPager(viewPager);

        tabLayout = (TabLayout) findViewById(R.id.tabs);
        tabLayout.setupWithViewPager(viewPager);


        mViewToReveal = findViewById(R.id.reveal_view);
        mRevealLayout = (RevealLayout) findViewById(R.id.reveal_layout);
        final View mRevealView=(View)
                findViewById(R.id.reveal_view);

         final FloatingActionButton mFab = (FloatingActionButton) findViewById(R.id.fab);
        mFab.setOnClickListener(new View.OnClickListener() {



            @Override
            public void onClick(View v) {
                mFab.setClickable(false); // Avoid naughty guys clicking FAB again and again...
                int[] location = new int[2];
                mFab.getLocationOnScreen(location);
                location[0] += mFab.getWidth() / 2;
                location[1] += mFab.getHeight() / 2;

                final Intent intent = new Intent(Home.this, SearchActivity.class);

                mRevealView.setVisibility(View.VISIBLE);
                mRevealLayout.setVisibility(View.VISIBLE);

                mRevealLayout.show(location[0], location[1]); // Expand from center of FAB. Actually, it just plays reveal animation.
                mFab.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        startActivity(intent);
                        /**
                         * Without using R.anim.hold, the screen will flash because of transition
                         * of Activities.
                         */
                        overridePendingTransition(0, R.anim.hold);
                    }
                }, 200); // 600 is default duration of reveal animation in RevealLayout
                mFab.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mFab.setClickable(true);
                        mRevealLayout.setVisibility(View.INVISIBLE);
                        mViewToReveal.setVisibility(View.INVISIBLE);
                    }
                }, 960); // Or some numbers larger than 600.
            }
        });


        client = new GoogleApiClient.Builder(Home.this).addApi(AppIndex.API).build();

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();

        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);



    }


    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_home, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        switch (item.getItemId()) {
            //noinspection SimplifiableIfStatement


            case R.id.action_notify:
                startActivity(new Intent(this, Home.class));
                return true;



            case R.id.action_checkbox1:
                if (item.isChecked()) item.setChecked(false);
                else item.setChecked(true);
                homeLayout.getResources().getColor(R.color.colorCheckbox);
                return true;

            case R.id.action_checkbox2:
                if (item.isChecked()) item.setChecked(false);
                else item.setChecked(true);
                homeLayout.getResources().getColor(R.color.colorCheckbox);
                return true;

            case action_checkbox3:
                if (item.isChecked()) item.setChecked(false);
                else item.setChecked(true);
                homeLayout.getResources().getColor(R.color.colorCheckbox);
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
        @SuppressWarnings("StatementWithEmptyBody")
        @Override
        public boolean onNavigationItemSelected (MenuItem item){
            // Handle navigation view item clicks here.
            int id = item.getItemId();

            if (id == R.id.nav_camera) {
                // Handle the camera action
            } else if (id == R.id.nav_gallery) {

            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            drawer.closeDrawer(GravityCompat.START);
            return true;


        }

    private void setupViewPager(ViewPager viewPager) {
        ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
        adapter.addFragment(new OneFragment(), "Breakfast");
        adapter.addFragment(new TwoFragment(), "Lunch");
        adapter.addFragment(new ThreeFragment(), "Merienda");
        viewPager.setAdapter(adapter);
    }

    class ViewPagerAdapter extends FragmentPagerAdapter {
        private final List<Fragment> mFragmentList = new ArrayList<>();
        private final List<String> mFragmentTitleList = new ArrayList<>();

        public ViewPagerAdapter(FragmentManager manager) {
            super(manager);
        }

        @Override
        public Fragment getItem(int position) {
            return mFragmentList.get(position);
        }

        @Override
        public int getCount() {
            return mFragmentList.size();
        }

        public void addFragment(Fragment fragment, String title) {
            mFragmentList.add(fragment);
            mFragmentTitleList.add(title);
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return mFragmentTitleList.get(position);
        }

    }

and activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <com.example.jovie.canteen.RevealLayout
        android:id="@+id/reveal_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="invisible">

        <View
            android:id="@+id/reveal_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="invisible"/>

    </com.example.jovie.canteen.RevealLayout>

    <include
        layout="@layout/app_bar_home"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_home"
        app:menu="@menu/activity_home_drawer"
        android:background="#ffffff" />

It seems that I didn't missed anything right now, no wonder the reveal circle animation doesn't work.
Looking forward to it, thanks.

next()时重影

在4.4 oppo 手机会出现重影。 vivo ,三星等其他手机都是好的。

RevealLayout reverse animation for FragmentActivity

Hi. First of all thanks for such a great piece of code. I really liked it. I have a minor request for FragmentActivity class. Can you please provide RevealLayout reverse animation as well when we go to previous fragment by pressing back?

event.getX() to event.getRawX()

I was trying to make my reveal animation end at the tapped coordinates. For a long time, I could not figure it out even though I was using the code from your demo app: layout.hide((int) event.getX(), (int) event.getY());

Then I stumbled upon this Stack Overflow thread and figured that I should use event.getRawX() instead of event.getX(). It worked like a charm in one go! I would suggest that you consider making this change (or I can issue a PR) in your demo app. This is so that people, in search of an answer, do not end up hard-coding extra pixel to x-y coordinates like: layout.hide((int) event.getX() + 320, (int) event.getY() + 160);

More often than not, people would like to have "absolute coordinates, relative to the screen."

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.