用过微信的朋友朋友都见过微信中点击对方头像显示会加载大图,先贴两张图片说明下:

这种UI效果对用户的体验不错,今天突然有了灵感,试着去实现,结果就出来了。。

下面说说我的思路:

1.点击图片时跳转到另一个activity,然后显示加载的效果,即progressbar

2.显示图片的之前先弹出自定义dialog,然后模拟加载一段时间后,显示整张大图片,要全屏显示,并且有类似微信中左上角滑出的动画效果

下面说说我的实现过程:

1.新建一个布局文件main.xml,其中只是放一个图片,布局

其中的android:onClick="show_click"是声名一个点击方法,然后再代码中实现,类似c#中


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"   
    android:layout_height="match_parent"
    android:padding="10dp"
     >     <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:src="@drawable/xiaohei"
        android:onClick="show_click"
        tools:context=".MianActivity" /> </RelativeLayout>

2.新建加载效果的布局文件dialog_imageloading.xml,设置整体布局为linearlayout,并且设置居中熟悉gravity和背景为透明,然后放一个progressbar


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/transparent"
    android:gravity="center"
    android:orientation="vertical" >     <ProgressBar
        android:id="@+id/progressBar1"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@android:color/transparent" /> </LinearLayout>

3.然后新建一个显示大图片的布局imageshower.xml,其中只是放了一张图片,设置整体背景为黑色


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000"
    android:gravity="center" >     <ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/xiaohei_big" /> </LinearLayout>

4.MainActivity中的代码只是实现了show_click方法

public void show_click(View v){
     startActivity(new Intent(this,ImageShower.class));
    }

5.ImageShower中的代码:


其中定义了一个handler过两秒后去关闭dialog,重写了父类的onTouchEvent方法,关闭当前activity

6.ImageLoadingDialog中是自定义对话框,继承自Dialog,必须实现onCreate方法和至少一个构造函数

其中ImageloadingDialogStyle为样式文件,统一写在res/values/styles/


 <style name="ImageloadingDialogStyle" parent="android:Theme.Dialog">
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowFrame">@null</item><!--无边框-->
        <item name="android:windowNoTitle">true</item><!--没有标题-->
        <item name="android:windowIsFloating">true</item><!--是否浮在activity之上-->
        <item name="android:windowIsTranslucent">true</item><!--背景是否半透明-->
        <item name="android:windowContentOverlay">@null</item><!--对话框是否有遮盖 -->
        <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item><!--动画样式-->
        <item name="android:backgroundDimEnabled">true</item><!--背景是否模糊-->
    </style>

7.最后是ImageShower的样式


 <style name="ImageScale" parent="android:Theme.Black.NoTitleBar">
        <item name="android:windowAnimationStyle">@style/AnimHead</item>
        <item name="android:windowNoTitle">true</item>
        <!-- 无标题 -->
        <item name="android:windowFullscreen">true</item>
        <!-- 设置全屏显示 -->
        <item name="android:windowFrame">@null</item>
        <!-- 边框 -->
        <item name="android:windowIsFloating">false</item>
        <!-- 是否浮现在activity之上 -->
        <item name="android:windowIsTranslucent">true</item>
        <!-- 半透明 -->
        <item name="android:windowBackground">@android:color/black</item>
        <item name="android:backgroundDimEnabled">false</item>
        <!-- 模糊 -->
    </style>

其中的AnimHead也是样式

 <style name="AnimHead" parent="@android:style/Animation">
        <item name="android:windowEnterAnimation">@anim/head_in</item>
        <item name="android:windowExitAnimation">@anim/head_out</item>
    </style>

head_in和head_out是定义在res/anim中

head_in:


<?xml version="1.0" encoding="utf-8"?>
<!-- 左上角扩大-->
  <scale   xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"  
        android:fromXScale="0.001" 
        android:toXScale="1.0"   
        android:fromYScale="0.001"   
        android:toYScale="1.0"   
        android:pivotX="15%"  
        android:pivotY="25%"  
        android:duration="200" />  

head_out:


<?xml version="1.0" encoding="utf-8"?>
<!-- 左上角缩小 -->
  <scale   xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"  
        android:fromXScale="1.0"   
        android:toXScale="0.001"   
        android:fromYScale="1.0"   
        android:toYScale="0.001"   
        android:pivotX="15%"  
        android:pivotY="25%"  
        android:duration="200" />  
   

所有的实现代码实现都完了。。还需要代码工程的可以email me~~~~~~~

下载:点击我!!!

android高仿微信UI点击头像显示大图片效果的更多相关文章

  1. android高仿微信UI点击头像显示大图片效果, Android 使用ContentProvider扫描手机中的图片,仿微信显示本地图片效果

    http://www.cnblogs.com/Jaylong/archive/2012/09/27/androidUI.html http://blog.csdn.net/xiaanming/arti ...

  2. Android 高仿微信头像截取 打造不一样的自定义控件

    转载请表明出处:http://blog.csdn.net/lmj623565791/article/details/39761281,本文出自:[张鸿洋的博客] 1.概述 前面已经写了关于检测手势识别 ...

  3. Android 高仿微信6.0主界面 带你玩转切换图标变色

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/41087219,本文出自:[张鸿洋的博客] 1.概述 学习Android少不了模仿 ...

  4. Android 高仿微信实时聊天 基于百度云推送

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/38799363 ,本文出自:[张鸿洋的博客] 一直在仿微信界面,今天终于有幸利用百 ...

  5. Android 高仿微信即时聊天 百度云为基础的推

    转载请注明出处:http://blog.csdn.net/lmj623565791/article/details/38799363 ,本文出自:[张鸿洋的博客] 一直在仿微信界面,今天最终有幸利用百 ...

  6. Android 高仿微信支付键盘

    现在很多app的支付.输入密码功能,都已经开始使用自定义数字键盘,不仅更加方便.其效果着实精致. 下面带着大家学习下,如何高仿微信的数字键盘,可以拿来直接用在自身的项目中. 先看下效果图: 1. 自定 ...

  7. Android 高仿微信语音聊天页面高斯模糊效果

    目前的应用市场上,使用毛玻璃效果的APP随处可见,比如用过微信语音聊天的人可以发现,语音聊天页面就使用了高斯模糊效果. 先看下效果图: 仔细观察上图,我们可以发现,背景图以用户头像为模板,对其进行了高 ...

  8. Android高仿微信(一)——如何消除启动时的白屏

    默认情况下,APP启动时会先把屏幕刷成白色,然后才绘制第一个Activity中的View,这两个步骤之间的延迟会造成启动后先看到白屏(时间大概为1秒左右).时间不长,但是我们也看到,一般的APP时不存 ...

  9. android高仿微信拍照、多选、预览、删除(去除相片)相冊功能

    先声明授人与鱼不如授人与渔,仅仅能提供一个思路,当然须要源代码的同学能够私下有偿问我要源代码:QQ:508181017 工作了将近三年时间了,一直没正儿八经的研究系统自带的相冊和拍照,这回来个高仿微信 ...

随机推荐

  1. 保障MySQL安全的14个最佳方法

    MySQL数据库一贯以高性能.高可性和易用性著称,它已经成为世界上最流行的开源数据库.大量的个人.WEB开发者.大型公司等都在其网站.关键系统.软件包中广泛使用MySQL数据库.        通常, ...

  2. CocoaPods报错:The dependency `xxx` is not used in any concrete target

    官网是这样给推荐的: 在创建Podfile的时候,用这种格式使用, platform :ios, '8.0' use_frameworks! target 'MyApp' do pod 'AFNetw ...

  3. 武汉科技大学ACM :1001: 零起点学算法34——继续求多项式

    Problem Description 输入1个正整数n, 计算1+(1+2)+(1+2+3)+...+(1+2+3+...+n) Input 输入正整数n(多组数据) Output 输出1+(1+2 ...

  4. Yandex 2013Q(Atoms: There and Back Again-贪心+模拟+List)

    Atoms: There and Back Again Time limit 2 seconds Memory limit 256Mb Input stdin Output stdout Legend ...

  5. onchar

    void CMfcView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)//Windows响应函数 { // TODO: Add your messag ...

  6. memcache实例

    <?php class demo { private $str_attr; private $int_attr; public function __get($name) { return $t ...

  7. 不要依赖hibernate的二级缓存

    一.hibernate的二级缓存   如果开启了二级缓存,hibernate在执行任何一次查询的之后,都会把得到的结果集放到缓存中,缓存结构可以看作是一个hash table,key是数据库记录的id ...

  8. python内置函数(4)

    12.pow:      >>> 2**10 1024 >>> pow(2,10) 1024 13.repr():忽略.. 14.reversed():反转.. 1 ...

  9. 64位系统ADB

    应该把ADB文件放在C:\Windows\SysWOW64目录下面,而不是System32下.

  10. Altium Designer规划电路板

           所谓规划电路板就是根据电路的规模以及用户的需求,确定所要制作电路板的物理外形尺寸和电气边界.电路板规划的原则是在满足用户要求的前提下,使板面美观而且利于后面的布线工作. 1. 定义板的外 ...