How to add Circular Layout Manager

In our previous article we discuss about some Andoroid layout library like AwesomeLayoutManager, dynamicLayoutManager and Two Panel Layout but today we discuss Custom Layout Manager for Recycler View.

Circular Layout Manager

Custom Layout Manager for Recycler View which lays out its child views in circular or elliptical fashion

Scroll Wheel functionality implemented along with Circular Relative Layout

Integeration

Use the following dependency snippet in your app level build.gradle file to include this library in your project:

dependencies {
  
    compile 'com.github.kapil93:circular-layout-manager:1.0.0'
}
Demo 1 : Circular Layout Manager
Demo 1 : Circular Layout Manager
Demo 2 : Circular Layout Manager
Demo 2 : Circular Layout Manager

Ex: Source code

private void initViews() {
        recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
        scrollWheel = (ScrollWheel) findViewById(R.id.scroll_wheel);

        addItemButton = (FloatingActionButton) findViewById(R.id.add_item_button);
        scrollWheelToggleButton = (FloatingActionButton) findViewById(R.id.scroll_wheel_toggle_button);
    }

 

private void setViews() {
       initializeList();
       recyclerView.setAdapter(new RecyclerViewAdapter(getApplicationContext(), list));
       recyclerView.addItemDecoration(new RecyclerItemDecoration());
       recyclerView.setLayoutManager(new CircularLayoutManager(getApplicationContext(), 200, -100));
       recyclerView.addOnItemTouchListener(new OnRecyclerItemClickListener(getApplicationContext(),
               new OnRecyclerItemClickListener.OnItemClickListener() {
           @Override
           public void OnItemClick(RecyclerView parent, int childIndex) {
               Toast.makeText(MainActivity.this, ((TextView) parent.getChildAt(childIndex)
                       .findViewById(R.id.event)).getText(), Toast.LENGTH_SHORT).show();
           }
       }));

       scrollWheel.setRecyclerView(recyclerView);
       scrollWheel.setScrollWheelEnabled(false);
       scrollWheel.setHighlightTouchAreaEnabled(false);
       //scrollWheel.setConsumeTouchOutsideTouchAreaEnabled(false);
       scrollWheel.setTouchAreaThickness(50);
       scrollWheel.setOnItemClickListener(new OnItemClickListener() {
           @Override
           public void onItemClick(ScrollWheel scrollWheel, int childIndex) {
               Toast.makeText(MainActivity.this, "OC " + ((TextView) scrollWheel.getRecyclerView()
                       .getChildAt(childIndex).findViewById(R.id.event)).getText(), Toast.LENGTH_SHORT).show();
           }

           @Override
           public void onItemLongClick(ScrollWheel scrollWheel, int childIndex) {
               Toast.makeText(MainActivity.this, "OLC " + ((TextView) scrollWheel.getRecyclerView()
                       .getChildAt(childIndex).findViewById(R.id.event)).getText(), Toast.LENGTH_SHORT).show();
           }
       });

       addItemButton.setOnClickListener(this);
       scrollWheelToggleButton.setOnClickListener(this);
   
Hope you like this comparison. Please share your thought and experience in comment section.

By Ponglang Petrung

Administrator and PJ at Kamibit Thailand, Android Developer at CodeGears Co., Ltd. and Android Developer, and iOS Application Developer at Appdever

Share your thoughts

Leave a Reply

Loading Facebook Comments ...
Loading Disqus Comments ...