Add points based on the following example
Android: Use Viewpager to move left and right to toggle pictures (simple version)
Effect preview:
Because you want to place the dots on the image, modify the layout to a relative layout:
<?XML version= "1.0" encoding= "Utf-8"?><Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" > <!--Switch Card - <Android.support.v4.view.ViewPagerAndroid:id= "@+id/viewpager"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content" > </Android.support.v4.view.ViewPager> <!--Dot Dot - <LinearLayoutAndroid:id= "@+id/viewgroup"Android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"Android:layout_alignparentbottom= "true"Android:layout_marginbottom= "40DP"android:gravity= "Center_horizontal"android:orientation= "Horizontal" > </LinearLayout> </Relativelayout>
Program added:
Privateprivate// parcel Point linearlayoutprivate ViewGroup Group
Group =(ViewGroup) Findviewbyid (R.id.viewgroup); //How many pictures there are , how many dots?Imageviews =Newimageview[pageview.size ()]; for(intI =0;i<pageview.size (); i++) {ImageView=NewImageView (mainactivity. This); Imageview.setlayoutparams (NewLayoutparams (20,20)); Imageview.setpadding (20, 0, 20, 0); Imageviews[i]=ImageView; //The default first graph shows selected state if(i = = 0) {Imageviews[i].setbackgroundresource (r.drawable.page_indicator_focused); } Else{imageviews[i].setbackgroundresource (r.drawable.page_indicator_unfocused); } group.addview (Imageviews[i]); } //PageView Listener classGuidepagechangelistenerImplementsonpagechangelistener{@Override Public voidOnpagescrollstatechanged (intarg0) { //TODO auto-generated Method Stub} @Override Public voidOnpagescrolled (intARG0,floatArg1,intarg2) { //TODO auto-generated Method Stub} @Override//If you switch, set the current point to the selected background, and the other settings do not have the background selected . Public voidOnpageselected (intarg0) { //TODO auto-generated Method Stub for(inti=0;i<imageviews.length;i++) {Imageviews[arg0].setbackgroundresource (r.drawable.page_indicator_focused); if(arg0! =i) {imageviews[i].setbackgroundresource (r.drawable.page_indicator_unfocused); } } } } //Binding Listener EventsViewpager.setonpagechangelistener (NewGuidepagechangelistener ());
>>>>>>>>>>>>>>>> Example Download