├── README.md ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── allen │ │ └── supertextview │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── hjj │ │ │ └── compositepicture │ │ │ ├── BitmapUtils.java │ │ │ ├── MainActivity.java │ │ │ └── ShareAppDialog.java │ └── res │ │ ├── anim │ │ ├── dialog_share_enter_anim.xml │ │ └── dialog_share_exit_anim.xml │ │ ├── drawable │ │ ├── bg_stroke_gray_e5e5e5.xml │ │ ├── bg_white_radio.xml │ │ └── sel_share_btn.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ └── dialog_app_share.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── red_circle.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── icon_share_close.png │ │ ├── icon_share_no_select.png │ │ ├── icon_share_qq.png │ │ ├── icon_share_qqzone.png │ │ ├── icon_share_select.png │ │ ├── icon_share_weibo.png │ │ ├── icon_share_weixin.png │ │ └── icon_share_weixincircle.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── allen │ └── supertextview │ └── ExampleUnitTest.java ├── build.gradle ├── build ├── generated │ └── mockable-android-25.jar └── intermediates │ └── dex-cache │ └── cache.xml ├── git_composite_picture.iml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── img-storage └── device-2018-06-14-170236.png ├── library └── library.iml ├── local.properties └── settings.gradle /README.md: -------------------------------------------------------------------------------- 1 | # 合成图片 2 | 3 | ![Image text](https://github.com/huangjiajie/CompositePicture/blob/master/img-storage/device-2018-06-14-170236.png) 4 | 5 | 1.支持动态合成昵称,头像,背景图等元素生成图片,并可支持显示元素的位置大小间距。 6 | 2.使用到强大的bitmap,Canvas,Paint 等绘制图片技术点。 7 | 3.参考于抖音的分享界面,支持分享图片,链接。 8 | 9 | 10 | ###欢迎热心的读者给star✨✨,你的鼓励是我前进的动力💗💗##### 11 | 12 | ##作者的联系方式: 13 | QQ:1009530461 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.1" 6 | defaultConfig { 7 | applicationId "com.hjj.compositepicture" 8 | minSdkVersion 18 9 | targetSdkVersion 22 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | productFlavors { 21 | } 22 | } 23 | 24 | dependencies { 25 | compile fileTree(include: ['*.jar'], dir: 'libs') 26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 27 | exclude group: 'com.android.support', module: 'support-annotations' 28 | }) 29 | compile 'com.android.support:appcompat-v7:25.0.1' 30 | compile 'com.github.bumptech.glide:glide:3.8.0' 31 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 32 | 33 | testCompile 'junit:junit:4.12' 34 | } 35 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/allen/supertextview/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.allen.supertextview; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.allen.supertextview", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/hjj/compositepicture/BitmapUtils.java: -------------------------------------------------------------------------------- 1 | package com.hjj.compositepicture; 2 | 3 | import android.content.ContentResolver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.res.Resources; 7 | import android.database.Cursor; 8 | import android.graphics.Bitmap; 9 | import android.graphics.Bitmap.CompressFormat; 10 | import android.graphics.Bitmap.Config; 11 | import android.graphics.BitmapFactory; 12 | import android.graphics.Canvas; 13 | import android.graphics.Color; 14 | import android.graphics.Matrix; 15 | import android.graphics.Paint; 16 | import android.graphics.PorterDuff; 17 | import android.graphics.PorterDuffXfermode; 18 | import android.graphics.Typeface; 19 | import android.media.ThumbnailUtils; 20 | import android.net.Uri; 21 | import android.os.Environment; 22 | import android.provider.MediaStore; 23 | import android.provider.MediaStore.Images.ImageColumns; 24 | import android.text.Spannable; 25 | import android.text.SpannableString; 26 | import android.text.TextUtils; 27 | import android.text.style.ImageSpan; 28 | 29 | import java.io.BufferedOutputStream; 30 | import java.io.ByteArrayOutputStream; 31 | import java.io.File; 32 | import java.io.FileNotFoundException; 33 | import java.io.FileOutputStream; 34 | import java.io.IOException; 35 | import java.io.InputStream; 36 | import java.net.URL; 37 | import java.net.URLConnection; 38 | import java.text.SimpleDateFormat; 39 | import java.util.Date; 40 | import java.util.regex.Matcher; 41 | import java.util.regex.Pattern; 42 | 43 | 44 | public class BitmapUtils { 45 | 46 | private final static String Tag = BitmapUtils.class.getSimpleName(); 47 | 48 | 49 | /** 50 | * 组合涂鸦图片和源图片 51 | * 52 | * @param src 源图片 53 | * @param watermark 涂鸦图片 54 | * @return 55 | */ 56 | public static Bitmap setBitmapImage(Context context, Bitmap src, Bitmap watermark, String userName) { 57 | 58 | 59 | Bitmap circleBitmap = createCircleBitmap(watermark); 60 | Bitmap whitheCircleBitmap = createWhitheCircleBitmap(watermark); 61 | 62 | // 另外创建一张图片 63 | Bitmap newb = Bitmap.createBitmap(src.getWidth(), src.getHeight(), Config.ARGB_8888);// 创建一个新的和SRC长度宽度一样的位图 64 | Canvas canvas = new Canvas(newb); 65 | 66 | canvas.drawBitmap(src, 0, 0, null);// 在 0,0坐标开始画入原图片src 67 | int width = ((src.getWidth() / 2) - (circleBitmap.getWidth() / 2)); 68 | int height = ((src.getHeight() / 2) - (circleBitmap.getWidth() / 2)); 69 | 70 | canvas.drawBitmap(whitheCircleBitmap, width, height - 100, null); // 白色圆形中间位置 71 | canvas.drawBitmap(circleBitmap, width, height - 100, null); // 涂鸦图片画到原图片中间位置 72 | 73 | 74 | Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 75 | paint.setColor(Color.RED); 76 | paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); 77 | paint.setTextSize(dip2px(context, 12)); 78 | 79 | //判断是否含有数字 80 | String regEx = "[^0-9]"; 81 | Pattern p = Pattern.compile(regEx); 82 | Matcher m = p.matcher(userName); 83 | String strNum = m.replaceAll("").trim(); 84 | 85 | //当有数字时,会影响居中显示,原因是数字长度比文本小 86 | int textPx=0; 87 | if (TextUtils.isEmpty(strNum)) { 88 | textPx = dip2px(context, 12) * userName.length(); 89 | } else { 90 | textPx = dip2px(context, 12) * userName.length()-(dip2px(context, 6)*(strNum.length())); 91 | } 92 | 93 | int textWidth = (src.getWidth() / 2) - ((textPx / 2)); 94 | 95 | canvas.drawText(userName, textWidth, height + 230, paint); 96 | 97 | canvas.save(Canvas.ALL_SAVE_FLAG); 98 | canvas.restore(); 99 | 100 | circleBitmap.recycle(); 101 | circleBitmap = null; 102 | 103 | return newb; 104 | } 105 | 106 | 107 | private static Bitmap createCircleBitmap(Bitmap resource) { 108 | //获取图片的宽度 109 | int width = resource.getWidth(); 110 | Paint paint = new Paint(); 111 | //设置抗锯齿 112 | paint.setAntiAlias(true); 113 | 114 | //创建一个与原bitmap一样宽度的正方形bitmap 115 | Bitmap circleBitmap = Bitmap.createBitmap(width, width, Bitmap.Config.ARGB_8888); 116 | //以该bitmap为低创建一块画布 117 | Canvas canvas = new Canvas(circleBitmap); 118 | 119 | 120 | //以(width/2, width/2)为圆心,width/2为半径画一个圆 121 | canvas.drawCircle(width / 2, width / 2, (width / 2 - 40), paint); 122 | 123 | //设置画笔为取交集模式 124 | paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); 125 | //裁剪图片 126 | canvas.drawBitmap(resource, 0, 0, paint); 127 | 128 | canvas.drawARGB(0, 0, 0, 0); 129 | 130 | return circleBitmap; 131 | } 132 | 133 | 134 | private static Bitmap createWhitheCircleBitmap(Bitmap resource) { 135 | //获取图片的宽度 136 | int width = resource.getWidth(); 137 | Paint paint = new Paint(); 138 | //设置抗锯齿 139 | paint.setAntiAlias(true); 140 | 141 | //创建一个与原bitmap一样宽度的正方形bitmap 142 | Bitmap circleBitmap = Bitmap.createBitmap(width, width, Bitmap.Config.ARGB_8888); 143 | //以该bitmap为低创建一块画布 144 | Canvas canvas = new Canvas(circleBitmap); 145 | canvas.drawARGB(0, 0, 0, 0); 146 | // 生成白色的 147 | paint.setColor(Color.WHITE); 148 | //设置画笔为取交集模式 149 | paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_ATOP)); 150 | //以(width/2, width/2)为圆心,width/2为半径画一个圆 151 | canvas.drawCircle(width / 2, width / 2, ((width / 2) - 30), paint); 152 | 153 | return circleBitmap; 154 | } 155 | 156 | 157 | public static int dip2px(Context context, float dipValue) { 158 | if (context == null) { 159 | return (int) (dipValue * 1 + 0.5f); 160 | } 161 | final float scale = context.getResources().getDisplayMetrics().density; 162 | 163 | return (int) (dipValue * scale + 0.5f); 164 | } 165 | 166 | 167 | /** 168 | * 把batmap 转file 169 | * 170 | * @param bitmap 171 | */ 172 | public static File saveBitmapFile(Bitmap bitmap) { 173 | 174 | String filepath = "/sdcard/zhiershareappimage.jpg"; 175 | File file = new File(filepath);//将要保存图片的路径 176 | 177 | try { 178 | BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file)); 179 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos); 180 | bos.flush(); 181 | bos.close(); 182 | } catch (IOException e) { 183 | e.printStackTrace(); 184 | } 185 | return file; 186 | } 187 | 188 | 189 | 190 | } 191 | 192 | -------------------------------------------------------------------------------- /app/src/main/java/com/hjj/compositepicture/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.hjj.compositepicture; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | import android.widget.Button; 7 | 8 | 9 | 10 | public class MainActivity extends AppCompatActivity { 11 | 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_main); 17 | 18 | Button button = (Button) findViewById(R.id.button); 19 | 20 | button.setOnClickListener(new View.OnClickListener() { 21 | @Override 22 | public void onClick(View v) { 23 | 24 | ShareAppDialog shareAppDialog=new ShareAppDialog(MainActivity.this); 25 | shareAppDialog.show(); 26 | 27 | } 28 | }); 29 | 30 | 31 | 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/hjj/compositepicture/ShareAppDialog.java: -------------------------------------------------------------------------------- 1 | package com.hjj.compositepicture; 2 | 3 | import android.app.Activity; 4 | import android.app.Dialog; 5 | import android.content.Context; 6 | import android.graphics.Bitmap; 7 | import android.graphics.Color; 8 | import android.os.Message; 9 | import android.text.TextUtils; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.Window; 13 | import android.view.WindowManager; 14 | import android.widget.ImageView; 15 | import android.widget.LinearLayout; 16 | import android.widget.RelativeLayout; 17 | import android.widget.TextView; 18 | 19 | import com.bumptech.glide.Glide; 20 | import com.bumptech.glide.request.animation.GlideAnimation; 21 | import com.bumptech.glide.request.target.SimpleTarget; 22 | import java.io.File; 23 | import java.util.ArrayList; 24 | import java.util.concurrent.ExecutionException; 25 | 26 | /** 27 | * Created by hjj on 17/12/28. 28 | */ 29 | 30 | public class ShareAppDialog implements View.OnClickListener { 31 | 32 | private Context mContext; 33 | private View mDialogView; 34 | private Dialog mDialog; 35 | private LinearLayout lly_weixin_circle; 36 | private LinearLayout lly_weixin; 37 | private LinearLayout lly_weibo; 38 | private RelativeLayout rly_photo; 39 | private RelativeLayout rly_url; 40 | private ImageView iv_select_photo; 41 | private ImageView iv_photo_bg; 42 | private ImageView iv_select_url; 43 | private ImageView iv_icon; 44 | private TextView tv_url_des; 45 | private ImageView iv_close; 46 | private Bitmap iconBitmap; 47 | private String shareImageUrl; 48 | private View top_view; 49 | private File imageFile; 50 | 51 | 52 | public ShareAppDialog(Context context) { 53 | this.mContext = context; 54 | mDialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_app_share, null); 55 | 56 | iniDialog(); 57 | } 58 | 59 | 60 | private void iniDialog() { 61 | 62 | mDialog = new Dialog(mContext, R.style.dialog); 63 | mDialog.setContentView(mDialogView); 64 | 65 | Window dialogWindow = mDialog.getWindow(); 66 | WindowManager.LayoutParams params = dialogWindow.getAttributes(); 67 | WindowManager wm = (WindowManager) mContext 68 | .getSystemService(Context.WINDOW_SERVICE); 69 | int width = wm.getDefaultDisplay().getWidth(); 70 | params.width = width; 71 | mDialog.setCanceledOnTouchOutside(true); 72 | 73 | dialogWindow.setWindowAnimations(R.style.sharedialogWindowAnim); // 设置窗口弹出动画 74 | 75 | 76 | lly_weixin_circle = (LinearLayout) mDialogView.findViewById(R.id.lly_weixin_circle); 77 | lly_weixin = (LinearLayout) mDialogView.findViewById(R.id.lly_weixin); 78 | lly_weibo = (LinearLayout) mDialogView.findViewById(R.id.lly_weibo); 79 | rly_photo = (RelativeLayout) mDialogView.findViewById(R.id.rly_photo); 80 | rly_photo = (RelativeLayout) mDialogView.findViewById(R.id.rly_photo); 81 | rly_url = (RelativeLayout) mDialogView.findViewById(R.id.rly_url); 82 | iv_select_photo = (ImageView) mDialogView.findViewById(R.id.iv_select_photo); 83 | iv_photo_bg = (ImageView) mDialogView.findViewById(R.id.iv_photo_bg); 84 | iv_select_url = (ImageView) mDialogView.findViewById(R.id.iv_select_url); 85 | iv_icon = (ImageView) mDialogView.findViewById(R.id.iv_icon); 86 | tv_url_des = (TextView) mDialogView.findViewById(R.id.tv_url_des); 87 | iv_close = (ImageView) mDialogView.findViewById(R.id.iv_close); 88 | top_view = (View) mDialogView.findViewById(R.id.top_view); 89 | 90 | 91 | lly_weixin_circle.setOnClickListener(this); 92 | lly_weixin.setOnClickListener(this); 93 | lly_weibo.setOnClickListener(this); 94 | iv_close.setOnClickListener(this); 95 | iv_select_photo.setOnClickListener(this); 96 | iv_select_url.setOnClickListener(this); 97 | rly_photo.setOnClickListener(this); 98 | rly_url.setOnClickListener(this); 99 | iv_photo_bg.setOnClickListener(this); 100 | top_view.setOnClickListener(this); 101 | 102 | 103 | iv_select_photo.setSelected(true); 104 | iv_select_url.setSelected(false); 105 | rly_url.setBackgroundColor(Color.WHITE); 106 | rly_photo.setBackgroundColor(mContext.getResources().getColor(R.color.gray)); 107 | 108 | 109 | iv_icon.setImageResource(R.mipmap.ic_launcher); 110 | tv_url_des.setText("我在知耳等你来!"); 111 | 112 | 113 | new Thread(new Runnable() { 114 | @Override 115 | public void run() { 116 | try { 117 | 118 | iconBitmap = Glide.with(mContext).load(R.mipmap.ic_launcher).asBitmap().centerCrop().into(300, 300).get(); 119 | 120 | 121 | mHandler.sendEmptyMessage(100); 122 | } catch (InterruptedException e) { 123 | e.printStackTrace(); 124 | } catch (ExecutionException e) { 125 | e.printStackTrace(); 126 | } 127 | } 128 | }).start(); 129 | 130 | 131 | 132 | 133 | } 134 | 135 | 136 | android.os.Handler mHandler = new android.os.Handler(new android.os.Handler.Callback() { 137 | 138 | @Override 139 | public boolean handleMessage(Message msg) { 140 | if (msg.what == 100) { 141 | 142 | String url = "https://dev.img.zhiervip.com/official/share/7120bf239ca3624fbde517a17cbac791.jpg"; 143 | 144 | if (!TextUtils.isEmpty(url)) { 145 | 146 | Glide.with(mContext).load(url).asBitmap().into(new SimpleTarget() { 147 | @Override 148 | public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) { 149 | 150 | 151 | if (resource != null && iconBitmap != null) { 152 | 153 | Bitmap imageBitmap = BitmapUtils.setBitmapImage(mContext, resource, iconBitmap, "我是姓名"); 154 | iv_photo_bg.setImageBitmap(imageBitmap); 155 | 156 | imageFile = BitmapUtils.saveBitmapFile(imageBitmap); 157 | 158 | 159 | } 160 | 161 | } 162 | }); 163 | 164 | 165 | } 166 | 167 | 168 | } 169 | 170 | return false; 171 | } 172 | }); 173 | 174 | 175 | public void show() { 176 | if (mDialog != null) { 177 | if (mContext instanceof Activity) { 178 | if (((Activity) mContext).isFinishing()) { 179 | return; 180 | } 181 | } 182 | mDialog.show(); 183 | } 184 | } 185 | 186 | public void dismiss() { 187 | if (mDialog != null) { 188 | mDialog.dismiss(); 189 | } 190 | } 191 | 192 | 193 | @Override 194 | public void onClick(View v) { 195 | switch (v.getId()) { 196 | 197 | case R.id.lly_weibo: 198 | dismiss(); 199 | break; 200 | 201 | case R.id.lly_weixin_circle: 202 | 203 | dismiss(); 204 | 205 | break; 206 | 207 | case R.id.lly_weixin: 208 | 209 | dismiss(); 210 | 211 | break; 212 | 213 | case R.id.iv_close: 214 | dismiss(); 215 | break; 216 | 217 | case R.id.iv_select_url://选择链接 218 | case R.id.rly_url: 219 | 220 | iv_select_url.setSelected(true); 221 | iv_select_photo.setSelected(false); 222 | 223 | rly_photo.setBackgroundColor(Color.WHITE); 224 | rly_url.setBackgroundColor(mContext.getResources().getColor(R.color.gray)); 225 | 226 | 227 | break; 228 | 229 | case R.id.iv_select_photo://选择图片 230 | case R.id.rly_photo: 231 | 232 | iv_select_photo.setSelected(true); 233 | iv_select_url.setSelected(false); 234 | rly_url.setBackgroundColor(Color.WHITE); 235 | rly_photo.setBackgroundColor(mContext.getResources().getColor(R.color.gray)); 236 | 237 | 238 | break; 239 | 240 | 241 | 242 | 243 | 244 | case R.id.top_view: 245 | dismiss(); 246 | break; 247 | 248 | } 249 | } 250 | 251 | 252 | } 253 | -------------------------------------------------------------------------------- /app/src/main/res/anim/dialog_share_enter_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/anim/dialog_share_exit_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_stroke_gray_e5e5e5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_white_radio.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sel_share_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 |