AutoScrollViewPager


Source link: https://github.com/fccaikai/AutoScrollViewPager

##AutoViewPager

##Download

Gradle:

in module's build.gradle,use:


 repositories {

jcenter()

maven {
 url "https://jitpack.io" 
}

  
}
 

replace:


 repositories {

jcenter()
  
}
 

in app's build.gradle,add:

compile 'com.kcode.github:autoScrollViewPager:1.0.1' 

##Usage

  • in layout

    
     <com.kcode.autoscrollviewpager.view.AutoScrollViewPager
    
    android:id="@+id/viewPager"
    
    android:layout_width="match_parent"
    
    android:layout_height="220dp">
    
      </com.kcode.autoscrollviewpager.view.AutoScrollViewPager> 
  • in activity:

    
    
     public class MainActivity extends AppCompatActivity {
    
      private AutoScrollViewPager mViewPager;
    
      private String[] paths = {
    "https://ss3.baidu.com/-fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=c493b482b47eca800d053ee7a1229712/8cb1cb1349540923abd671df9658d109b2de49d7.jpg",
    
      "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=45fbfa5555da81cb51e684cd6267d0a4/2f738bd4b31c8701491ea047237f9e2f0608ffe3.jpg",
    
      "https://ss2.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=ae0e95c0fc1986185e47e8847aec2e69/0b46f21fbe096b63eb314ef108338744ebf8ac62.jpg",
    
      "https://ss3.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=1fad2b46952397ddc9799f046983b216/dc54564e9258d109c94bbb13d558ccbf6d814de2.jpg",
    
      "https://ss1.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=ff0999f6d4160924c325a51be406359b/86d6277f9e2f070861ccd4a0ed24b899a801f241.jpg"
    }
    ;
    
      @Override
    
    protected void onCreate(Bundle savedInstanceState) {
    
     super.onCreate(savedInstanceState);
    
     setContentView(R.layout.activity_main);
    
    mViewPager = (AutoScrollViewPager) findViewById(R.id.viewPager);
    
    BaseViewPagerAdapter<String> adapter = new BaseViewPagerAdapter<String>(this,listener) {
    
      @Override
    
      public void loadImage(ImageView view, int position, String url) {
    
    Picasso.with(MainActivity.this).load(url).into(view);
    
      
    }
    
     @Override
    
      public void setSubTitle(TextView textView, int position, String s) {
    
    textView.setText(s);
    
      
    }
    
     
    }
    ;
    
     mViewPager.setAdapter(adapter);
    
    adapter.add(initData());
    
     
    }
    
      private List<String> initData() {
    
     List<String> data = new ArrayList<>();
    
     Picture picture ;
    
     for (int i = 0 ; i < paths.length ;i++){
    
      data.add(paths[i]);
    
     
    }
    
     return data;
    
    }
    
      @Override
    
    protected void onDestroy() {
    
     super.onDestroy();
    
     mViewPager.onDestroy();
    
    }
    
      private BaseViewPagerAdapter.OnAutoViewPagerItemClickListener listener = new BaseViewPagerAdapter.OnAutoViewPagerItemClickListener<String>() {
    
    @Override
    
     public void onItemClick(int position, String url) {
    
      Toast.makeText(getApplicationContext(),
    
     url, Toast.LENGTH_SHORT).show();
    
     
    }
    
    }
    ;
      
    }
    
     

    Override public void loadImage(ImageView view, int position, String url) to load image to ImageView.

    Override public void setSubTitle(TextView textView, int position, String s) to set text to subTitle.

  • OnClick

    private BaseViewPagerAdapter.OnAutoViewPagerItemClickListener listener = new BaseViewPagerAdapter.OnAutoViewPagerItemClickListener<String>() {
    
     @Override
    
    public void onItemClick(int position, String url) {
    
     Toast.makeText(getApplicationContext(),
    
     url, Toast.LENGTH_SHORT).show();
    
    }
    
      
    }
    ; 

    init OnClickListener

    public BaseViewPagerAdapter(Context context, List<T> data,OnAutoViewPagerItemClickListener listener)  
  • PointLayout add xmlns:app="http://schemas.android.com/apk/res-auto" to layout file. And , user app:point_layout="right|center".

sample: AutoViewPager

Resources

A ListView with "floor animation".

This library for Android projects adds Greasemonkey-compatible user script support to standard WebView components.

Android Library to simplify SharedPreferences use with code generation.

Helper to ask runtime permission on android marshmallow

The library takes care themselves to check whether a permit has already been agreed by the user or not. If the user has given consent call, the system dialog for the acceptance.

A customizable extension of Android Switches that supports also more than 2 items.

Android-Retainable-Tasks is an easy to use mini-library for easy asynchronous background tasking with callback support to the UI. This library is based on the Android AsyncTask implementation but with support for retaining tasks and therefore surviving configuration changes (orientation).

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes