Androidimageslider pictures of open source projects multi-pose carousel

Source: Internet
Author: User

Effect

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/82/78/wKiom1dWQ5rjSmuxABmOGXoaYoo659.gif "title=" Demo.gif "alt=" Wkiom1dwq5rjsmuxabmogxoayoo659.gif "/>

First, join the Gradle

Compile ' com.squareup.picasso:picasso:2.5.2 ' compile ' com.nineoldandroids:library:2.4.0 ' compile ' Com.daimajia.slider:library:[email protected] ' compile ' com.daimajia.androidanimations:library:[email protected] '

And then add permissions

<!--need to access the network pictures Plus-<!--<uses-permission android:name= "Android.permission.INTERNET"/>--> < Uses-permission android:name= "Android.permission.READ_EXTERNAL_STORAGE"/>

Because I'm using a local image, I only added one.


Layout file:

<?xml version= "1.0"  encoding= "Utf-8"? >  <relativelayout xmlns:android= "http ://schemas.android.com/apk/res/android "      xmlns:custom="/http Schemas.android.com/apk/res-auto "      xmlns:tools=" http://schemas.android.com/ Tools "      android:layout_width=" Match_parent "       android:layout_height= "Match_parent"       android:paddingbottom= "@dimen/ Activity_vertical_margin "      android:paddingleft=" @dimen/activity_horizontal_ Margin "      android:paddingright=" @dimen/activity_horizontal_margin "       android:paddingtop= "@dimen/activity_vertical_margin"        android:gravity= "Center"       tools:context= " Com.lg.imagesliderdemo.MainActivity ">        <com.daimajia.slider.library.SliderLayout           android:id= "@+id/slider"           android: Layout_width= "Match_parent"           android:layout_height= " 200DP "          custom:auto_cycle=" true "           custom:indicator_visibility= "Visible"            custom:pager_animation= "Accordion"            custom:pager_animation_span= "1100"  />         <com.daimajia.slider.library.Indicators.PagerIndicator           android:id= "@+id/ind_pager"            Android:layout_width= "Wrap_conteNT "          android:layout_height=" Wrap_content "           android:gravity= "Center"  />  </ Relativelayout>

Core code in Mainactivity:

public class mainactivity extends appcompatactivity {         private sliderlayout sliderlayout;      private  pagerindicator indicator;      private int[] imgurl =  new int[]{R.drawable.img_one,               R.drawable.img_two, R.drawable.img_three, R.drawable.img_four};          @Override       protected void oncreate ( Bundle savedinstancestate)  {           Super.oncreate (savedinstancestate);           setcontentview ( R.layout.activity_main);           init ();       }        private void init ()  {           sliderLayout =  (sliderlayout)  findviewbyid (r.id.slider);           indicator =  (Pagerindicator)  findviewbyid (r.id.ind_ Pager);          for  (Int url : imgurl)  {              textsliderview  customsliderview = new textsliderview (This);               customSliderView                       .image (URL)                         .setscaletype (baseslideRView.ScaleType.Fit);               Sliderlayout.addslider (Customsliderview);          }           sliderlayout.setpresettransformer ( SliderLayout.Transformer.ZoomOut);           Sliderlayout.setcustomanimation (New descriptionanimation ());           sliderlayout.setduration (;          ) Sliderlayout.setcustomindicator (indicator);       }  }

Of course, depending on the needs of the changes to achieve the desired effect

Source Address: http://down.51cto.com/data/2221974

This article is from the "Android Development column" blog, be sure to keep this source http://liuyvhao.blog.51cto.com/11690759/1786878

Androidimageslider pictures of open source projects multi-pose carousel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.