微信小程序修改头像图片怎么修改?看头像

扫码关注有意思吧微信
欢迎同学们转载但请注明出处及链接,媒体、微信请获得授权,联系QQ:。
15:56:43 发布 丨 5982710 人浏览
你可能对以下文章感兴趣
≡ 本站荣誉 ≡
本站带宽由
提供,特此鸣谢!
有意思吧版权所有微信头像怎么换 微信更换头像图文教程
- 绿茶文章中心
&&&&&&&&&微信头像怎么换 微信更换头像图文教程
微信头像怎么换 微信更换头像图文教程
作者:佚名
来源:绿茶软件园
  微信头像怎么换呢?新的一年,大家是不是也想给自己的微信换个新头像呢?那么怎么换呢?下面绿茶小豆子为大家介绍微信更换头像图文教程。
  微信更换头像图文教程:
  1.进入微信,点击右下角【我】
  2.点击第一行的头像
  3.点击【头像】文字
  4.选择【拍照】或【照片】,也可点击左下角更换照片目录
  5.选择好照片后可调整大小,点击使用即可
绿茶软件园小编推荐阅读:
22:58:38绿茶软件园网友[福建省泉州市]
谢谢,改好了。
12:09:30绿茶网友[四川省绵阳市]
简单明了,便捷,赞一个。
本类推荐本类排行
热门软件热门标签仿微信通过拍照、本地图片然后裁剪完美更换头像 - CSDN博客
仿微信通过拍照、本地图片然后裁剪完美更换头像
其实更换头像这个功能是个老梗了,写的人也很多,但是我没有看见过特别让我满意的,没办法,只能自己搞了。这里面我只说难点吧,最后的会附上完整的代码。
这里面涉及到的功能有哪些呢?
大概有:拍照 、扫描本地图片、裁剪、可以拖动放大缩小的图片、圆形头像,自认为还是比较不错的,代码风格可能能有改进,大家可以自行修改!~
一、首页main.activity
public class MainActivity extends AppCompatActivity {
private CircleImageView headerP
private TextView textV
private static final String IMAGE_FILE_LOCATION = ConstantSet.LOCALFILE;
Uri imageU
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
headerPic=(CircleImageView)findViewById(R.id.headerImage);
textView=(TextView)findViewById(R.id.updateImages);
textView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
View uv = getLayoutInflater().from(MainActivity.this).inflate(R.layout.upload_user_pic, null);
TextView photograph = (TextView) uv.findViewById(R.id.Photograph);
TextView selectPic = (TextView) uv.findViewById(R.id.selectImage_from_local);
TextView dimissDialoag = (TextView) uv.findViewById(R.id.dimiss_dialoag);
builder.setView(uv);
final AlertDialog alertDialog = builder.show();
MyDialoagListener myDialoagListener = new MyDialoagListener(alertDialog);
photograph.setOnClickListener(myDialoagListener);
selectPic.setOnClickListener(myDialoagListener);
dimissDialoag.setOnClickListener(myDialoagListener);
file = new File(IMAGE_FILE_LOCATION);
if(!file.exists()){
SDCardUtils.makeRootDirectory(IMAGE_FILE_LOCATION);
file=new File(IMAGE_FILE_LOCATION+ConstantSet.USERTEMPPIC);
imageUri = Uri.fromFile(file);
* 头像更改监听
private class MyDialoagListener implements View.OnClickListener {
private AlertDialog alertD
public MyDialoagListener(AlertDialog alertDialog) {
this.alertDialog = alertD
public void onClick(View v) {
switch (v.getId()) {
case R.id.Photograph:
alertDialog.dismiss();
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, ConstantSet.TAKEPICTURE);
case R.id.selectImage_from_local:
Intent sintent = new Intent(MainActivity.this, SelectImagesFromLocalActivity.class);
startActivityForResult(sintent, ConstantSet.SELECTPICTURE);
alertDialog.dismiss();
case R.id.dimiss_dialoag:
alertDialog.dismiss();
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != RESULT_OK) {
switch (requestCode) {
case ConstantSet.TAKEPICTURE:
Intent tcutIntent = new Intent(MainActivity.this, ClippingPageActivity.class);
tcutIntent.putExtra("type", "takePicture");
startActivityForResult(tcutIntent, ConstantSet.CROPPICTURE);
case ConstantSet.SELECTPICTURE:
Intent scutIntent = new Intent(MainActivity.this, ClippingPageActivity.class);
scutIntent.putExtra("type", "selectPicture");
scutIntent.putExtra("path",data.getStringExtra("path"));
startActivityForResult(scutIntent, ConstantSet.CROPPICTURE);
case ConstantSet.CROPPICTURE:
byte[] bis = data.getByteArrayExtra("result");
Bitmap bitmap = BitmapFactory.decodeByteArray(bis, 0, bis.length);
headerPic.setImageBitmap(bitmap);
首页效果大致就是这个样子:
二、SelectImagesFromLocalActivity
public class SelectImagesFromLocalActivity extends AppCompatActivity implements
View.OnClickListener,ImagesFolderPopupWindow.FinishOnItemClickListener,AdapterView.OnItemClickListener {
private DisplayImageOptions options = null;
private GridView mgridV
private SpinnerProgressD
private LinearLayout mSelectI
private TextView mFolderN
private ImageGridViewA
private ImagesFolderPopupW
private ArrayList&ImageBean& marrayList=new ArrayList&&();
private ArrayList&ImageFolderBean& arrayList=new ArrayList&&();
private HashMap&String,ArrayList&ImageBean&&
mgroupMap=new HashMap&&();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_select_from_local);
msp=new SpinnerProgressDialoag(this);
initTitle();
mgridView=(GridView)findViewById(R.id.imagesGridView);
mgridView.setOnItemClickListener(this);
mSelectImages=(LinearLayout)findViewById(R.id.selectImagesFromFolder);
mSelectImages.setOnClickListener(this);
mFolderName=(TextView)findViewById(R.id.imagesFolderName);
initImageLoader();
madapter=new ImageGridViewAdapter(this,options);
mgridView.setAdapter(madapter);
pop=new ImagesFolderPopupWindow(this,options);
pop.setFinishOnItemClickListener(this);
new RequestLocalImages().execute();
private void initTitle() {
ImageView rightImage = (ImageView) findViewById(R.id.id_img_right);
TextView title = (TextView) findViewById(R.id.id_title);
ImageView back = (ImageView) findViewById(R.id.id_back);
rightImage.setVisibility(View.GONE);
title.setText(getResources().getString(R.string.images));
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
SelectImagesFromLocalActivity.this.finish();
public void onItemClick(AdapterView&?& parent, View view, int position, long id) {
ImageBean imageBean=(ImageBean)parent.getItemAtPosition(position);
String path=imageBean.getImagePath();
File file=new File(path);
if(file.exists()) {
Intent itToClip = new Intent();
itToClip.putExtra("path", path);
setResult(RESULT_OK, itToClip);
this.finish();
public void onClick(View v) {
switch (v.getId()){
case R.id.selectImagesFromFolder:
pop.showPopupWindow(v);
public void OnFinishedClick(String name) {
madapter.setArrayList(mgroupMap.get(name));
mFolderName.setText(name);
private class
RequestLocalImages extends AsyncTask&String,Integer,String&{
public RequestLocalImages() {
protected String doInBackground(String... params) {
Cursor imageCursor = getContentResolver().
query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[]{MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID},
null, null, MediaStore.Images.Media._ID);
mgroupMap.put(getResources().getString(R.string.all_images),marrayList);
if (imageCursor != null && imageCursor.getCount() & 0) {
while (imageCursor.moveToNext()) {
ImageBean item = new ImageBean(imageCursor.
getString(imageCursor.getColumnIndex(MediaStore.Images.Media.DATA)));
mgroupMap.get(getResources().getString(R.string.all_images)).add(item);
String parentPath=new File(item.getImagePath()).getParentFile().getName();
if(!mgroupMap.containsKey(parentPath)){
ArrayList&ImageBean& arrayList=new ArrayList&&();
arrayList.add(item);
mgroupMap.put(parentPath,arrayList);
mgroupMap.get(parentPath).add(item);
subGroupOfImage(mgroupMap);
return null;
protected void onPostExecute(String s) {
madapter.setArrayList(mgroupMap.get(getResources().getString(R.string.all_images)));
pop.setArrayList(arrayList);
super.onPostExecute(s);
private void subGroupOfImage(HashMap&String,ArrayList&ImageBean&&
mgroupMap){
if(mgroupMap==null||mgroupMap.size()==0){
Iterator&Map.Entry&String,ArrayList&ImageBean&&& iterator=mgroupMap.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry&String,ArrayList&ImageBean&& entry=iterator.next();
ImageFolderBean ifb=new ImageFolderBean();
ifb.setFirstImage(entry.getValue().get(0).getImagePath());
ifb.setFolderName(entry.getKey());
ifb.setImages(entry.getValue().size());
if(!entry.getKey().equals(getResources().getString(R.string.all_images))){
ifb.setIsSelected(false);
arrayList.add(ifb);
ifb.setIsSelected(true);
arrayList.add(0,ifb);
private void initImageLoader() {
if (options == null) {
DisplayImageOptions.Builder displayBuilder = new DisplayImageOptions.Builder();
displayBuilder.cacheInMemory(true);
displayBuilder.cacheOnDisk(true);
displayBuilder.showImageOnLoading(R.mipmap.default_photo);
displayBuilder.showImageForEmptyUri(R.mipmap.default_photo);
displayBuilder.considerExifParams(true);
displayBuilder.bitmapConfig(Bitmap.Config.RGB_565);
displayBuilder.imageScaleType(ImageScaleType.EXACTLY);
displayBuilder.displayer(new FadeInBitmapDisplayer(300));
options = displayBuilder.build();
if (!ImageLoader.getInstance().isInited()) {
ImageLoaderConfiguration.Builder loaderBuilder = new ImageLoaderConfiguration.Builder(getApplication());
loaderBuilder.memoryCacheSize(getMemoryCacheSize());
File cacheDir = new File(getExternalCacheDir() + File.separator + ConstantSet.IMAGE_CACHE_DIRECTORY);
loaderBuilder.diskCache(new LruDiskCache(cacheDir, DefaultConfigurationFactory.createFileNameGenerator(), 500 * 1024 * 1024));
} catch (IOException e) {
e.printStackTrace();
ImageLoader.getInstance().init(loaderBuilder.build());
private int getMemoryCacheSize() {
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
int screenWidth = displayMetrics.widthP
int screenHeight = displayMetrics.heightP
return screenWidth * screenHeight * 4 * 3;
效果如图所示:
三、裁剪中最重要的可以拖动、缩放的imageView,当然很多代码网上都有,只不过我稍加改动
PerfectControlImageView
public class PerfectControlImageView extends ImageView {
float x_down = 0;
float y_down = 0;
PointF start = new PointF();
PointF mid = new PointF();
float oldDist = 1f;
float oldRotation = 0;
Matrix matrix = new Matrix();
Matrix matrix1 = new Matrix();
Matrix savedMatrix = new Matrix();
private static final int NONE = 0;
private static final int DRAG = 1;
private static final int ZOOM = 2;
int mode = NONE;
boolean matrixCheck = false;
int widthS
int heightS
private int titleH
public PerfectControlImageView(Context context) {
this(context, null);
public PerfectControlImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray typedArray=context.obtainStyledAttributes
(attrs, R.styleable.PerfectControlImageView,defStyleAttr,0);
titleHeight=typedArray.getDimensionPixelSize(R.styleable.PerfectControlImageView_titleHeight,
(int)TypedValue.PLEX_UNIT_DIP,59,getResources().getDisplayMetrics()));
widthScreen= ScreenUtils.getScreenWidth(context);
heightScreen=ScreenUtils.getScreenHeight(context)-
ScreenUtils.getStatusHeight(context)-
matrix = new Matrix();
public PerfectControlImageView(Context context, AttributeSet attrs) {
this(context, attrs,0);
public void setImageBitmap(Bitmap bm) {
this.gintama=
matrix.postTranslate((widthScreen-gintama.getWidth())/2,(heightScreen-gintama.getHeight())/2);
protected void onDraw(Canvas canvas) {
canvas.save();
canvas.drawBitmap(gintama, matrix, null);
canvas.restore();
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
mode = DRAG;
x_down = event.getX();
y_down = event.getY();
savedMatrix.set(matrix);
case MotionEvent.ACTION_POINTER_DOWN:
mode = ZOOM;
oldDist = spacing(event);
savedMatrix.set(matrix);
midPoint(mid, event);
case MotionEvent.ACTION_MOVE:
if (mode == ZOOM) {
matrix1.set(savedMatrix);
float newDist = spacing(event);
float scale = newDist / oldD
matrix1.postScale(scale, scale, mid.x, mid.y);
matrixCheck = matrixCheck();
if (matrixCheck == false) {
matrix.set(matrix1);
invalidate();
} else if (mode == DRAG) {
matrix1.set(savedMatrix);
matrix1.postTranslate(event.getX() - x_down, event.getY()
- y_down);
matrixCheck = matrixCheck();
matrixCheck = matrixCheck();
if (matrixCheck == false) {
matrix.set(matrix1);
invalidate();
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
mode = NONE;
return true;
private boolean matrixCheck() {
float[] f = new float[9];
matrix1.getValues(f);
float x1 = f[0] * 0 + f[1] * 0 + f[2];
float y1 = f[3] * 0 + f[4] * 0 + f[5];
float x2 = f[0] * gintama.getWidth() + f[1] * 0 + f[2];
float y2 = f[3] * gintama.getWidth() + f[4] * 0 + f[5];
float x3 = f[0] * 0 + f[1] * gintama.getHeight() + f[2];
float y3 = f[3] * 0 + f[4] * gintama.getHeight() + f[5];
float x4 = f[0] * gintama.getWidth() + f[1] * gintama.getHeight() + f[2];
float y4 = f[3] * gintama.getWidth() + f[4] * gintama.getHeight() + f[5];
double width = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
if (width & widthScreen / 3 || width & widthScreen * 3) {
return true;
if ((x1 & widthScreen / 3 && x2 & widthScreen / 3
&& x3 & widthScreen / 3 && x4 & widthScreen / 3)
|| (x1 & widthScreen * 2 / 3 && x2 & widthScreen * 2 / 3
&& x3 & widthScreen * 2 / 3 && x4 & widthScreen * 2 / 3)
|| (y1 & heightScreen / 3 && y2 & heightScreen / 3
&& y3 & heightScreen / 3 && y4 & heightScreen / 3)
|| (y1 & heightScreen * 2 / 3 && y2 & heightScreen * 2 / 3
&& y3 & heightScreen * 2 / 3 && y4 & heightScreen * 2 / 3)) {
return true;
return false;
private float spacing(MotionEvent event) {
float x = event.getX(0) - event.getX(1);
float y = event.getY(0) - event.getY(1);
return (float)Math.sqrt(x * x + y * y);
private void midPoint(PointF point, MotionEvent event) {
float x = event.getX(0) + event.getX(1);
float y = event.getY(0) + event.getY(1);
point.set(x / 2, y / 2);
private float rotation(MotionEvent event) {
double delta_x = (event.getX(0) - event.getX(1));
double delta_y = (event.getY(0) - event.getY(1));
double radians = Math.atan2(delta_y, delta_x);
return (float) Math.toDegrees(radians);
public Bitmap CreatNewPhoto() {
Bitmap bitmap = Bitmap.createBitmap(widthScreen, heightScreen,
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap(gintama, matrix, null);
canvas.save(Canvas.ALL_SAVE_FLAG);
canvas.restore();
四、ClippingPageActivity
public class ClippingPageActivity extends AppCompatActivity {
private PerfectControlImageView imageV
private CuttingFrameView cuttingFrameV
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_clipping_page);
initTitle();
cuttingFrameView = (CuttingFrameView) findViewById(R.id.cutingFrame);
imageView = (PerfectControlImageView) findViewById(R.id.targetImage);
if (getIntent().getStringExtra("type").equals("takePicture")) {
bitmap = BitmapUtils.DecodLocalFileImage(ConstantSet.LOCALFILE + ConstantSet.USERTEMPPIC, this);
String path=getIntent().getStringExtra("path");
bitmap = BitmapUtils.DecodLocalFileImage(path, this);
if (bitmap != null) {
imageView.setImageBitmap(bitmap);
* 初始化title
private void initTitle() {
ImageView rightImage = (ImageView) findViewById(R.id.id_img_right);
TextView title = (TextView) findViewById(R.id.id_title);
TextView righttext=(TextView)findViewById(R.id.id_text_right);
ImageView back = (ImageView) findViewById(R.id.id_back);
rightImage.setVisibility(View.GONE);
righttext.setVisibility(View.VISIBLE);
title.setText(getResources().getString(R.string.picture_cutting));
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
ClippingPageActivity.this.finish();
righttext.setText(getResources().getString(R.string.sure));
righttext.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
SpinnerProgressDialoag sp=new SpinnerProgressDialoag(ClippingPageActivity.this);
sp.show();
Bitmap bitmap=cuttingFrameView.takeScreenShot(ClippingPageActivity.this);
SDCardUtils.saveMyBitmap(ConstantSet.LOCALFILE, ConstantSet.USERPIC, bitmap);
Intent it=new Intent();
ByteArrayOutputStream baos=new ByteArrayOutputStream();
pressFormat.JPEG, 100, baos);
byte [] bitmapByte =baos.toByteArray();
it.putExtra("result", bitmapByte);
setResult(RESULT_OK, it);
sp.dismiss();
ClippingPageActivity.this.finish();
主要的内容都在这里的,其它的代码,大家可以直接下载源码:
只要一份,最近积分不多啦。。O(∩_∩)O哈哈~
本文已收录于以下专栏:
相关文章推荐
【Android设置头像,手机拍照或从本地相册选取图片作为头像】
像微信、QQ、微博等社交类的APP,通常都有设置头像的功能,设置头像通常有两种方式:
1,让用户通过选择本地相册之类的图片库中已有...
先看效果图 :
最近公司的APP很多用户反应无法上传头像,于是打算修改原来头像裁剪的代码。参考微信、QQ、唱吧头像裁剪的操作,决定就仿微信头像裁剪来上传用户头像,在Android大神鸿洋的一篇高仿微信头像的博客(博客...
拍照——裁剪,或者是选择图片——裁剪,是我们设置头像或上传图片时经常需要的一组操作。上篇讲了Camera的使用,这篇讲一下我对图片裁剪的实现。背景
下面的需求都来自产品。
裁剪图片要像微信那样,拖动和...
转载请表明出处:http://blog.csdn.net/lmj/article/details/,本文出自:【张鸿洋的博客】1、概述前面已经写了关于检测手势识别的文...
他的最新文章
讲师:宋宝华
讲师:何宇健
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)如何修改微信群昵称和头像的办法_53货源网
如何修改微信群昵称和头像的办法共有84562人学习了本文 | 发布时间:
一、群昵称了解进而相交,相交进而熟悉,熟悉进而合作,这是规律!微信群昵称应该用好,里面包含有很丰富的信息,很利于群友们认识自己。微信群昵称修改方式:点击本群聊右上角小人标志,拉到最下面,点击“详细设置”,点击“我的群昵称”,输入保存即可。详细设置里选择“聊天中显示群昵称”选项即可在本群看到发言人的群昵称,其他群的昵称不变。修改微信群个人昵称方法步骤:1、打开自己想要修改群昵称的微信群,进入群聊天的窗口,点击右上角的群资料按钮,如图所示:随后在微信群设置中,往下翻,找到“我在本群的昵称”,然后修改,如图所示:最后输入在这个微信群的昵称,点击“保存”按钮就可以了,如图所示:&二、头像头像修改方式:在刚进入微信的界面上,点击最右上角竖排三个点的标识,然后点开,就看到头像,点击,进入你的照片夹,选择你满意的照片,然后可以放大后按确定,就OK了。头像一改,所有群都看到。
上一篇:下一篇:
微信群相关信息
一、群昵称了解进而相交,相交进而熟悉,熟悉进而合作,这是规律!微信群昵称应该用好,里面包含有很丰富的信息,很利于群友们认识自己。微信群昵称修改方式:点击本群聊右...
近日网络上面曝出了微信群红包赌博的消息引起一片哗然,对此微信称将严厉整顿微信群红包赌博,目前处理了8000余个涉赌群,下面来看下具体消息。6月16日消息,微信于...
微信群发怎么发呢?很简单,只要八步,你就可以实现微信如何群发的方法:很多微友一般的做法都是建立微群。而微群最多只能建立20人的聊天,同时是多人的聊天,谈不上群发...
微信6.3.16正式版来了,相信很多小伙伴对新功能是很期待的哦!今天,我们就来看看微信6.3.16正式版是如何玩转群里多人视频聊天的吧。微信6.3.16在群里视...
微信红包群接龙玩法有哪几种?微信红包群接龙有什么技巧吗?说微信群红包接龙也涉及聚众赌博嫌疑,是真还是假?在打算建立微信红包群玩微信红包接力的时候首先要设置好微信...
其它微信开店信息
1234567891011
热门微商货源
1234567891011
淘宝网店怎么开,找免费开网店货源,欢迎来到53网店货源网。本站的货源信息由会员发布,请妥善交易!
-|--|--|--|--|--|--|--|-
投诉、建议联系邮箱:9386542⒊◎qq.Com (请尽量发邮件联系) QQ: 广告联系 QQ: 交流QQ群:(禁止任何广告)
& 2006-, all rights reserved.

我要回帖

更多关于 怎样修改微信头像 的文章

 

随机推荐