Android碎纸机效果
1.总体思想
活用padding和margin
2.实现过程
 public class PopupShredderView extends FrameLayout{
     public PopupShredderView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         init();
     }
     public PopupShredderView(Context context, AttributeSet attrs) {
         super(context, attrs);
     init() ;
     }
     public PopupShredderView(Context context) {
         super(context);
     init();
     }
     private void init(){
       final LayoutInflater layoutInflater = LayoutInflater.from(context);
       mView = layoutInflater.inflate(R.layout.popup_shredder_clean, this, false);
       mCleanText1.setImageDrawable(themeManager.getDrawable(R.drawable.exit_clean_date));
       mCleanText2.setBackgroundDrawable(themeManager.getDrawable(R.drawable.exit_clean_result));
       mCleanText2.setVisibility(View.INVISIBLE);
     }
     public void update(int step, int offset){
             if (step == STEP_END) {
                    return;
                }
         int clean1Offset = mCleanText1.getMeasuredHeight() * step / STEP_END;
         int maxClean1Offset=mCleanText1.getMeasuredHeight();
         if (offset + clean1Offset < maxClean1Offset) {
             clean1Offset = clean1Offset + offset;
         } else {
             clean1Offset = maxClean1Offset;
         }
         mCleanText1.setPadding(0, clean1Offset, 0, 0);
         mCleanText2.setVisibility(View.VISIBLE);
         int clean2Offset = ((View) mCleanText2.getParent()).getMeasuredHeight() * (STEP_END - step)
                 / STEP_END;
         int maxClean2Offset= 0;
         if (clean2Offset - offset > maxClean2Offset) {
             clean2Offset = clean2Offset - offset;
         } else {
             clean2Offset = maxClean2Offset;
         }
         LinearLayout.LayoutParams layoutParams = (android.widget.LinearLayout.LayoutParams) mCleanText2
                 .getLayoutParams();
         layoutParams.bottomMargin = clean2Offset;
         mCleanText2.setLayoutParams(layoutParams);
         invalidate();
     }
 }
3.布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/menubar"
android:layout_width="192dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical" > <ImageView
android:id="@+id/exit_clean1"
android:layout_width="wrap_content"
android:layout_height="@dimen/popup_shredder_top_heigh"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="21dp"
android:contentDescription="@string/app_name"
android:scaleType="matrix" /> <LinearLayout
android:layout_width="wrap_content"
android:layout_height="@dimen/popup_shredder_top_heigh"
android:layout_marginLeft="28dp"
android:layout_marginTop="@dimen/popup_shredder_bottom_top_margin"
android:orientation="vertical" > <ImageView
android:id="@+id/exit_clean2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:contentDescription="@string/app_name" />
</LinearLayout> <ImageView
android:id="@+id/exit_clean3"
android:layout_width="wrap_content"
android:layout_height="@dimen/popup_shredder_delete_heigh"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/popup_shredder_delete_top_margin"
android:contentDescription="@string/app_name" /> </RelativeLayout>
Android碎纸机效果的更多相关文章
- 在Mac系统上配置Android真机调试环境
		
在Mac系统上配置Android真机调试环境 mac上配置安卓环境还说挺方便的,真机调试也比win上要好一些.win上被各种软件强行安装了xxx助手. 在mac上就了一个干净的感觉. 下载Androi ...
 - 【Android源代码下载】收集整理android界面UI效果源码
		
在Android开发中,Android界面UI效果设计一直都是很多童鞋关注的问题,今天给大家分享下大神收集整理的多个android界面UI效果,都是源码,都是干货,贡献给各位网友! 话不多说,直接上效 ...
 - android真机自动化测试
		
appium执行用例时报错问题: 问题解析: 一般该种情况都是因为来连接了多个设备,验证办法:cmd->执行adb devices 看结果是否是多个devices ,如果是这个问题,停掉多余设 ...
 - OpenJudge 2803 碎纸机 / Poj 1416 Shredding Company
		
1.链接地址: http://poj.org/problem?id=1416 http://bailian.openjudge.cn/practice/2803 2.题目: 总时间限制: 1000ms ...
 - Android真机测试,连接到本地服务器的方法
		
1. 前言 作为一名Android开发者,不管怎么说,都会经历使用Android真机来测试连接本地服务器这样的事情.这里所说的“本地服务器”大多数时候指的是:搭载有某种服务器软件的PC,例如搭载有To ...
 - Android 真机投影到PC端,真机投影工具;Vysor
		
Vysor可以把Android真机投影到PC端,也就是电脑上:手机端和PC端课同步操作: Vysor是Chrome浏览器的插件,我们想要添加这个插件需要FQ: 从这里可以直接下载:Vysor
 - Unity Frame Debugger连接Android真机调试
		
当用Profiler分析到不是代码导致的性能问题,当前场景最大的性能瓶颈是渲染时,或者自己写的Shader要调试时,都可以用Frame Debugger进行调试. 按下列步骤设置打包,既可以用Prof ...
 - Unity Profiler连接Android真机调试
		
Profiler在Editor模式就可以观看性能消耗,但是毕竟电脑配置高,跟手机真机环境还是有区别.实际开发中的优化还是推荐用真机测试. 因为IOS一般比Android手机的配置高,在Android平 ...
 - 使用ADB无线连接Android真机进行调试
		
使用ADB无线连接Android真机进行调试 其实这已经是一个很古老的知识了,记录一下备忘. 准备工作 手机和电脑需要在同一个局域网内 电脑上已经安装好ADB工具,可以是Mac或者Windows ...
 
随机推荐
- MySQL丨02丨忘记root用户密码怎么办?
			
软件:Mysql 版本:8.0.13 1. 先暂停mysql的服务,方法是在cmd里输入如下代码: net stop mysql 2. 在安装文件夹下创建一个文件:mysql-ini.txt (我的安 ...
 - TCP三次握手简单理解
 - oracle如何重做日志组
			
1.查询数据库中的重做日志组 SQL> select * from v$log; GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STA ...
 - day15-python之变量和递归
			
1.局部变量与全局变量 #!/usr/bin/env python # -*- coding:utf-8 -*- # name='lhf' # def change_name(): # global ...
 - python中的多任务
			
多任务 什么是任务 一个电脑运行这的软件 什么是多任务 电脑同时运行着的多个软件 多任务原理 时间片的轮转 并行与并发 并发:假的多任务,多个任务共用一个核 并行:正的多任务,一个核处理一个程序 生理 ...
 - Python数据结构--树遍历算法
			
''' 遍历是访问树的所有节点的过程,也可以打印它们的值. 因为所有节点都通过边(链接)连接,所以始终从根(头)节点开始. 也就是说,我们不能随机访问树中的一个节点. 这里介绍三种方式来遍历一棵树 - ...
 - C#中为什么不能再方法里定义静态变量(Static)
			
c#的静态变量是在对象生成的时候分配内存空间的,而不是函数执行的时候. 如果在函数里定义,那么这个变量就需要在函数执行的时候分配内存空间,这是C#不允许的,至于为什么不允许,个是因为垃圾回收机制的问题 ...
 - websocket个人理解总结
			
WebSocket 释义:聊天室.服务.套接字.协议 引用:https://www.ibm.com/developerworks/cn/web/1112_huangxa_websocket/index ...
 - MS SQLServer Update语法和实例
			
最常用的update语法是: 1 2 UPDATE TABLE_NAME SET column_name1 = VALUE WHRER column_name2 = VALUE 如果我的更新值Valu ...
 - WKWebView的了解
			
1. http://blog.csdn.net/chenyong05314/article/details/53735215 2. http://www.jianshu.com/p/6ba250744 ...