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 ...
随机推荐
- UVa-340-猜数字
#include <stdio.h> char ans[1000],gus[1000]; int num[10]; int main() { int n,cnt=1; while (sca ...
- vue 页面过渡效果
App.vue 模板 <template> <div id="app"> <transition :name="transition&quo ...
- Python面向对象之异常
异常的概念 程序在运行时,如果python解释器遇见一个错误,就会停止程序的运行,并且提示一些错误信息,这就是异常: 程序遇见错误停止执行并且提示错误信息,这个动作我们称之为抛出(raise)异常: ...
- Python的串口
要使用python中的串口,可以下载pywin32-224-cp36-cp36m-win_amd64.whl去安装或者pip install去安装. 调试下来,有一点很不爽,读取read()数据的ti ...
- jQuery.data() 的实现方式
jQuery.data() 的作用是为普通对象或 DOM Element 附加(及获取)数据. 下面将分三个部分分析其实现方式: 1. 用name和value为对象附加数据:即传入三个参数,第 ...
- Mybatis 缓存策略
听极客学院笔记 使用mybatis的缓存需要以下三步 一.在mybatis的config.xml中开启缓存 <settings> <setting name="cacheE ...
- 把以100000+4位随机码的登录账号(比如1000001234),赋予制单页面的权限,怎么写sql啊
insert into sys_user_role (user_id,role_id,office_id) select id,'000101100000000004UP',company_id f ...
- 按Esc按钮关闭layer弹窗
//按Esc关闭弹出框 $(document).ready(function () { }).keydown( function (e) { if (e.which === 27) { layer. ...
- 亲历dataguard的一些经验问答题
问题1:是否log_archive_dest_n=service中进程使用lgwr时(如log_archive_dest_2='service=DBSTD LGWR SYNC'),备库就一定要建立st ...
- VS Code 列编辑功能说明
新版本v1.13.1或者附近的版本中的列编辑功能已经调整. 一.多光标插入功能 Alt+鼠标左键,添加多光标输入 二.自由多行选择 Alt键+鼠标左键拖动选择各行的部分内容 三.列选择 Shift+A ...