First picture.
Click on the + number to select the picture
In fact, the addition itself is a ListView or Recyclerview
It's just a little special layout.
Item
<?xml version= "1.0" encoding= "Utf-8"?> xmlns: Android= "Http://schemas.android.com/apk/res/android" android:id= "@+id/rootview" android:layout_width= "WRAP_" Content "android:layout_height=" wrap_content "> <relativelayout android:layout_width=" wrap_content "android:l ayout_height= "Wrap_content" android:layout_marginleft= "7DP" android:layout_marginright= "7DP" Android:layout_ margintop= "14DP" android:background= "@drawable/shape_white_bg_corner" > <imageview android:id= "@+id/ivDisP Layitemphoto "android:layout_width=" match_parent "android:layout_height=" Match_parent "Android:contentDescription"
= "@null" android:scaletype= "Centercrop" android:layout_centerinparent= "true" android:layout_marginright= "8DP" android:layout_marginleft= "8DP" android:layout_margintop= "5DP" android:layout_marginbottom= "5DP"/> <Ima Geview android:id= "@+id/ivaddphoto" android:layout_width= "Match_parent" android:layout_height= "Match_parent" android:layout_centerinparent= "true" Android:backgroun d= "@color/white" android:scaletype= "Centercrop" android:src= "@mipmap/add_photo_refund" android:visibility= "Visibl E "/> <imageview android:id=" @+id/ivuploadingbg android:layout_width= "Match_parent" Android:layout_heigh t= "Match_parent" android:src= "@drawable/shape_grey_bg_corner" android:visibility= "Gone"/> <imageview and Roid:id= "@+id/iverror" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:layout_ce Nterinparent= "true" android:src= "@mipmap/icon_prompt" android:visibility= "Gone"/> <textview "android:id=" @+id/tvprogress "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "Android:layout_centerIn" Parent= "true" android:text= "0%" android:textcolor= "@color/white" android:textsize= "16sp" android:visibility= "G One "/> </relativelayout> <imageview android:id= "@+id/ivdelete android:layout_width=" wrap_content "android:layout_height=" WR Ap_content "android:layout_alignparentright=" true "android:src=" @mipmap/delete_photo "android:visibility=" Gone "/&
Gt
</liu.myrecyleviewchoosephoto.view.SquareRelativeLayout>
In adpater to determine whether a data is 0 and is not the last to add a picture on it.
@Override public
int GetItemCount () {
if (Mdatas = null | | mdatas.size () = = 0) {return
1;
} else if (mDa Tas.size () < Mmaxnum) {return
mdatas.size () + 1;
} else {return
mdatas.size ();
}}
Here we use a square, a container.
Package Liu.myrecyleviewchoosephoto.view;
Import Android.content.Context;
Import Android.util.AttributeSet;
Import Android.widget.RelativeLayout; /** * Square relativelayout * Created by Liu Nan on 2016/8/13 0013.16:07/public class Squarerelativelayout extends Relativel
ayout {public Squarerelativelayout (context) {super (context);
Public Squarerelativelayout (context, AttributeSet attrs) {Super (context, attrs); Squarerelativelayout (context, AttributeSet attrs, int defstyleattr) {Super (context, Attrs, Defstylea
TTR); @Override protected void onmeasure (int widthmeasurespec, int heightmeasurespec) {//set its own measurement results setmeasureddimensi
On (Getdefaultsize (0,widthmeasurespec), Getdefaultsize (0,heightmeasurespec));
/** * Measuring the * * int childwidthsize=getmeasuredwidth () of the child view;
The height is the same as the width Widthmeasurespec =measurespec.makemeasurespec (childwidthsize,measurespec.exactly);
Heightmeasurespec =widthmeasurespec; Super.onmeasure (widthMeasurespec, Heightmeasurespec);
}
}
No picture selector is written here
be interested to see here
Picture selector: Https://github.com/ln0491/PhotoView
Source: Https://github.com/ln0491/MyRecyleViewChoosePhoto
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.