本文为大家分享了类似微信朋友圈,点击+号图片,可以加图片功能,供大家参考,具体内容如下
<强> xml: 强>
& lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比; & lt; LinearLayout xmlns: android=" http://schemas.android.com/apk/res/android " xmlns:应用=" http://schemas.android.com/apk/res-auto " android: layout_width=" match_parent " android: layout_height=" match_parent " android: layout_marginTop=" 40 dp " 面向android:=按怪薄北? & lt; com.sw.demo.widget.NinePhotoView android: id=癅 + id/photoview” android: layout_width=" match_parent " android: layout_height=" wrap_content " 应用:ninephoto_hspace=" 10 dp” 应用:ninephoto_vspace=" 10 dp” 应用:rainbowbar_color=" @android:颜色/holo_blue_bright”比; & lt;/com.sw.demo.widget.NinePhotoView> >之前<强> NinePhotoView.java 强>
公开课NinePhotoView延伸ViewGroup { 公共静态最终int MAX_PHOTO_NUMBER=9; 私人int [] constImageIds={R.drawable。girl_0 R.drawable.girl_1, R.drawable。girl_2 R.drawable。girl_3 R.drawable.girl_4, R.drawable。girl_5 R.drawable。girl_6 R.drawable.girl_7, R.drawable。girl_8};//儿童水平空间的观点 int水平间距=跑龙套。dpToPx (10, getresource ());//垂直空间儿童的观点 int vSpace=跑龙套。dpToPx (10, getresource ());//每个子视图的宽度和高度。 int childWidth=0; int childHeight=0;//存储图片res id ArrayListmImageResArrayList=new ArrayList (9); 私人观点addPhotoView; 公共NinePhotoView(上下文语境){ 超级(上下文); } 公共NinePhotoView(上下文语境,AttributeSet attrs) { 这(上下文、attrs 0); } 公共NinePhotoView(上下文语境、AttributeSet attrs int defStyle) { 超级(上下文、attrs defStyle); TypedArray t=context.obtainStyledAttributes (attrs R.styleable。NinePhotoView, 0, 0); 水平间距=t.getDimensionPixelSize ( R.styleable。NinePhotoView_ninephoto_hspace、水平间距); vSpace=t.getDimensionPixelSize ( R.styleable。NinePhotoView_ninephoto_vspace vSpace); t.recycle (); addPhotoView=新的视图(上下文); addView (addPhotoView); mImageResArrayList。添加(新的整数()); } <>强测量强>
@Override 保护空白> @Override 保护无效alt=" Android仿微信朋友圈点击加号添加图片功能">以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
Android仿微信朋友圈点击加号添加图片功能