Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Page Curl Effect in android

    • 0
    • 0
    • 0
    • 0
    • 2
    • 0
    • 0
    • 0
    • 4.14k
    Comment on it

    In this tutorial, we will know that how to use page curl effect in android using images. We will discuss complete tutorial step by step .

    Step1- Introduction

    Page curl effect provides a 2D view while swapping pages using images. In this tutorial, we are going to implement page curl effect through a simple example using a library called numAndroidPageCurlEffect.

    Step2- Adding support library

    To use all Page Curl Effect  features in our application, we need to integrate support library in the project. So, open app's build.gradle file and add supporting library as a dependency.

    dependencies {
    compile 'app.num.numandroidpagecurleffect:numandroidpagecurleffect:1.0'
    }

     

    Step3- Creating a layout
    We will add the following code to our main XML file .

    <app.num.numandroidpagecurleffect.PageCurlView
         android:layout_width="match_parent"
         android:layout_height="fill_parent"
         android:id="@+id/pagecurl_view"
         android:background="@drawable/page1"/>
    
    

     

    Step4- Initializing the PageCurlView

    Initialize the PageCurlView in activity onCreate() method as others view.
     

    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            PageCurlView pageCurlView = (PageCurlView) findViewById(R.id.pagecurl_view);
        }
    }

     

    Step5- Creating an ArrayList

    We will create an array list of integer type in which will keep all images id .
     

    public class MainActivity extends AppCompatActivity {
     
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
     
            PageCurlView pageCurlView = (PageCurlView) findViewById(R.id.dcgpagecurlPageCurlView1);
     
            List<Integer> pages_id = new ArrayList<>();
            pages_id.add(R.drawable.page1);
            pages_id.add(R.drawable.page2);
     
        }
    }
    
    

     

    Step6- Call the setCurlView() method

    We need to pass this list of images in the setCurlView() method.
     

    public class MainActivity extends AppCompatActivity {
     
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
     
            PageCurlView pageCurlView = (PageCurlView) findViewById(R.id.dcgpagecurlPageCurlView1);
     
            List<Integer> pages_id = new ArrayList<>();
            pages_id.add(R.drawable.page1);
            pages_id.add(R.drawable.page2);
     
            pageCurlView.setCurlView(pages_id);
     
        }
    }
    
    

     

    Step7- Add page curl speed

    We can set curl speed using setCurSpeed() method. Its optional and by default can set 62.

    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            PageCurlView pageCurlView = (PageCurlView) findViewById(R.id.dcgpagecurlPageCurlView1);
    
            List<Integer> pages_id = new ArrayList<>();
            pages_id.add(R.drawable.page1);
            pages_id.add(R.drawable.page2);
    
            pageCurlView.setCurlView(pages_id);
            pageCurlView.setCurlSpeed(65);
    
        }
    }

     

 2 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: