The project has already image slider
successfully with WiewPagedIndicator
library. I just want to add curly page animation
. There are few topic for it in StackOverflow. All of them are so old. And I can't implement it to my project. Is there any easier way to add this animation in my project? How can solve this problem?
dependencies {
implementation 'me.relex:circleindicator:1.3.2'
implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
}
activity_brochure_detail.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Controllers.BrochureDetailActivity">
<android.support.constraint.ConstraintLayout
android:layout_width="300dp"
android:layout_height="500dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="@+id/constraintLayout2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar_activity_borchure_detail"
app:layout_constraintVertical_bias="0.0">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_alignParentTop="true"
android:layout_marginTop="100dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/indicator"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="8dp"
android:layout_marginBottom="32dp"
android:gravity="bottom"
android:padding="10dip"
app:centered="true"
app:fillColor="#df0623"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/pager"
app:layout_constraintStart_toStartOf="@+id/pager"
app:layout_constraintTop_toBottomOf="@+id/pager"
app:pageColor="#fff"
app:snap="false" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
BrochureDetailActivity.java
public class BrochureDetailActivity extends AppCompatActivity {
private static ViewPager mPager;
private static int currentPage = 0;
private static int NUM_PAGES = 0;
private Toolbar mToolbar;
private TextView toolbarTextViewBrochureDetail;
private String imgBrochure, marketNameBrochure, timeBrochure;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_brochure_detail);
sliderPic();
}
private void sliderPic(){
String[] urls;
if (marketNameBrochure.equals("Carrefour")) {urls = new String[] {getString(R.string.ayuzbir_brochure_url),
getString(R.string.ayuzbir_brochure_url),getString(R.string.ayuzbir_brochure_url)};
}
else {urls = new String[] {getString(R.string.bim_brochure_url)};}
mPager = findViewById(R.id.pager);
mPager.setAdapter(new SliderAdapter(BrochureDetailActivity.this, urls));
CirclePageIndicator indicator =
findViewById(R.id.indicator);
indicator.setViewPager(mPager);
final float density = getResources().getDisplayMetrics().density;
//Set circle indicator radius
indicator.setRadius(5 * density);
NUM_PAGES = urls.length;
// Auto start of viewpager
final Handler handler = new Handler();
final Runnable Update = new Runnable() {
public void run() {
if (currentPage == NUM_PAGES) {
currentPage = 0;
}
mPager.setCurrentItem(currentPage++, true);
}
};
// Pager listener over indicator
indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
currentPage = position;
}
@Override
public void onPageScrolled(int pos, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int pos) {
}
});
}
}