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碎纸机效果的更多相关文章

  1. 在Mac系统上配置Android真机调试环境

    在Mac系统上配置Android真机调试环境 mac上配置安卓环境还说挺方便的,真机调试也比win上要好一些.win上被各种软件强行安装了xxx助手. 在mac上就了一个干净的感觉. 下载Androi ...

  2. 【Android源代码下载】收集整理android界面UI效果源码

    在Android开发中,Android界面UI效果设计一直都是很多童鞋关注的问题,今天给大家分享下大神收集整理的多个android界面UI效果,都是源码,都是干货,贡献给各位网友! 话不多说,直接上效 ...

  3. android真机自动化测试

    appium执行用例时报错问题: 问题解析: 一般该种情况都是因为来连接了多个设备,验证办法:cmd->执行adb devices  看结果是否是多个devices ,如果是这个问题,停掉多余设 ...

  4. OpenJudge 2803 碎纸机 / Poj 1416 Shredding Company

    1.链接地址: http://poj.org/problem?id=1416 http://bailian.openjudge.cn/practice/2803 2.题目: 总时间限制: 1000ms ...

  5. Android真机测试,连接到本地服务器的方法

    1. 前言 作为一名Android开发者,不管怎么说,都会经历使用Android真机来测试连接本地服务器这样的事情.这里所说的“本地服务器”大多数时候指的是:搭载有某种服务器软件的PC,例如搭载有To ...

  6. Android 真机投影到PC端,真机投影工具;Vysor

    Vysor可以把Android真机投影到PC端,也就是电脑上:手机端和PC端课同步操作: Vysor是Chrome浏览器的插件,我们想要添加这个插件需要FQ: 从这里可以直接下载:Vysor

  7. Unity Frame Debugger连接Android真机调试

    当用Profiler分析到不是代码导致的性能问题,当前场景最大的性能瓶颈是渲染时,或者自己写的Shader要调试时,都可以用Frame Debugger进行调试. 按下列步骤设置打包,既可以用Prof ...

  8. Unity Profiler连接Android真机调试

    Profiler在Editor模式就可以观看性能消耗,但是毕竟电脑配置高,跟手机真机环境还是有区别.实际开发中的优化还是推荐用真机测试. 因为IOS一般比Android手机的配置高,在Android平 ...

  9. 使用ADB无线连接Android真机进行调试

    使用ADB无线连接Android真机进行调试   其实这已经是一个很古老的知识了,记录一下备忘. 准备工作 手机和电脑需要在同一个局域网内 电脑上已经安装好ADB工具,可以是Mac或者Windows ...

随机推荐

  1. MYSQL:WARN: Establishing SSL connection without server's identity verification is not recommended.

    WARN: Establishing SSL connection without server's identity verification is not recommended. Accordi ...

  2. Linux内核学习总览

    断断续续学习操作系统已经有大半年时间了,一直想系统地梳理一下. 正好借助<深入Linux内核架构> (Wolfgang Manuere 著,郭旭 译)汇总一下. 首先基础框架篇,Linux ...

  3. python3.x Day6 IO多路复用

    IO多路复用import asyncio 这个是异步IO模块 这个还不知道怎么用 select poll epoll 都是IO多路复用 windows 仅支持select linux2.6以后 支持e ...

  4. Java 多线程执行

    背景: 如果一个任务由多个子任务组成,子任务全部执行完成后然后由主线程对所有子任务结果进行封装,可以采用如下几种方式: 1.基于Guava ListenableFuture 进行: 2.基于Futur ...

  5. c和c++如何把一个整数转化为string

    c和c++如何把一个整数转化为string C++: 一.string转int的方式 采用最原始的string, 然后按照十进制的特点进行算术运算得到int,但是这种方式太麻烦,这里不介绍了. 采用标 ...

  6. CDOJ 1218 Pick The Sticks

    Pick The Sticks Time Limit: 15000/10000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others ...

  7. PHP加速之eaccelerator

    eaccelerator简介: eAccelerator是一个自由开放源码php加速器,优化和动态内容缓存,提高了php脚本的缓存性能,使得PHP脚本在编译的状态下,对服务器的开销几乎完全消除. 它还 ...

  8. Vim增强工具设置

    Vim增强工具设置操作准备:vim ~/.vimrc11. 缩进 & 制表符使 Vim 在创建新行的时候使用与上一行同样的缩进: set autoindent 2. 设置文件里的制表符 (TA ...

  9. POJ 1273 Drainage Ditches【图论,网络流】

    就是普通的网络流问题,想试试新学的dinic算法,这个算法暑假就开始看国家集训队论文了,之前一直都只用没效率的EK算法,真正学会这个算法还是开学后白书上的描述:dinic算法就是不断用BFS构建层次图 ...

  10. tree(poj 1741)

    题意:给一颗n个节点的树,每条边上有一个距离v(v<=1000).定义d(u,v)为u到v的最小距离.给定k值,求有多少点对(u,v)使u到v的距离小于等于k. /* 照着点分治模板敲了敲,有很 ...