ViewPagerArrow Material Desgin Drawer

Every once in a while, an Android developer might want to use a ViewPager without the added complexity of also using Fragments. A good example is an image gallery, where the user can swipe between different pictures. On these types of pages, all you really want to display is a view of static content (in this case, an image), so I’m going to walk you through how to utilize the ViewPager with just plain-old Views and layouts.

1. HomeActivity.java

package com.tutorialsee.viewpagerarrow;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class HomeActivity extends AppCompatActivity {
ImageView Button1,Button2,Button3,Button4,Button5,Button6,Button7;
Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
context = this;
Button1 = (ImageView) findViewById(R.id.button1);
Button2 = (ImageView) findViewById(R.id.button2);
Button3 = (ImageView) findViewById(R.id.button3);
Button4 = (ImageView) findViewById(R.id.button4);
Button5 = (ImageView) findViewById(R.id.button5);
Button6 = (ImageView) findViewById(R.id.button6);
Button7 = (ImageView) findViewById(R.id.button7);
Button1.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Intent i = new Intent(context, MainActivity.class);
overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);  
startActivity(i);



}
});

Button2.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Intent i = new Intent(context, Ink_Activity.class);
overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);  
startActivity(i);



}
});

Button3.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Intent i = new Intent(context, ViewPagerNews.class);
overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);  
startActivity(i);



}
});

Button4.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Intent i = new Intent(context, DefaultFragment.class);
overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);  
startActivity(i);



}
});

Button5.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Intent i = new Intent(context, CustomAnimationFragment.class);
overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);  
startActivity(i);



}
});

Button6.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Intent i = new Intent(context, SimpleViewsFragment.class);
overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);  
startActivity(i);



}
});

Button7.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Intent i = new Intent(context, StepperIndicatorActivity.class);
overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);  
startActivity(i);



}
});

}
}

2. activity_home.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#E3E2E2"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="1dp"
        android:layout_weight="1"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
             android:background="#ffffff"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/arrow"
             
                android:onClick="showInfoToast"
               />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="1dp"
            android:layout_weight="1"
            android:gravity="center"
            android:background="#ffffff"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:onClick="showDefaultToast"
                android:background="@drawable/inkviewpager" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="1dp"
        android:layout_marginLeft="1dp"
        android:layout_marginRight="1dp"
              
        android:layout_weight="1"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#ffffff"
            android:gravity="center"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/button3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/dotsss"
                android:onClick="showInfoToast"
                android:text="Double SeekBar"
                android:textColor="#607D8B"
                android:textSize="15sp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="1dp"
            android:layout_weight="1"
             android:background="#ffffff"
            android:gravity="center"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/button4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/dotee"
                android:onClick="showDefaultToast"
                android:text="SeekBar Value"
                android:textColor="#607D8B"
                android:textSize="15sp" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="1dp"
        android:layout_marginRight="1dp"
        android:layout_weight="1"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
              android:background="#ffffff"
            android:gravity="center"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/button5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/cc"
                android:onClick="showInfoToast"
                android:text="SeekBar TextSize"
                android:textColor="#607D8B"
                android:textSize="15sp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="1dp"
            android:layout_weight="1"
            android:gravity="center"
            android:background="#ffffff"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/button6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/er"
                android:onClick="showDefaultToast"
                android:text="Vertical SeekBar"
                android:textColor="#607D8B"
                android:textSize="15sp" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="1dp"
        android:layout_weight="1"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
              android:background="#ffffff"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/button7"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:onClick="showInfoToast"
                 android:background="@drawable/gg" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>