Wednesday, 30 August 2017

Create Simple CarouselView

step1:
compile 'com.synnapps:carouselview:0.1.4'

step 2:
<?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:orientation="vertical"    
android:layout_width="match_parent"    
android:layout_height="match_parent"    
tools:context="com.carousel.carouselview.MainActivity">
<com.synnapps.carouselview.CarouselView  
     android:id="@+id/carouselView"       
     android:layout_width="368dp"        
     android:layout_height="200dp"        
     app:fillColor="#FFFFFFFF"        
     app:pageColor="#00000000"        
     app:radius="6dp"       
     app:slideInterval="3000"       
     app:strokeColor="#FF777777"       
     app:strokeWidth="1dp"       
     tools:layout_editor_absoluteY="0dp"       
     tools:layout_editor_absoluteX="8dp" />
</LinearLayout>

step3:
public class MainActivity extends AppCompatActivity
       int[] sampleImages = {R.drawable.image1
                             R.drawable.image2,
                             R.drawable.image3,
                             R.drawable.image4,
                             R.drawable.image5};
    CarouselView carouselView;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.carousel_view);
        carouselView=(CarouselView)findViewById(R.id.carouselView);
        carouselView.setPageCount(sampleImages.length);
        ImageListener imageListener = new ImageListener() {
    @Override    public void setImageForPosition(int position, ImageView imageView) {
        imageView.setImageResource(sampleImages[position]);
    }
};
carouselView.setImageListener(imageListener);}

No comments:

Post a Comment

HOW TO CREATE CIRCLE IMAGE VIEW

Step 1: implementation 'de.hdodenhof:circleimageview:3.0.0' Step 2: <de.hdodenhof.circleimageview.CircleImageView xmlns:ap...