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>

最新文章

  1. [LeetCode] Rearrange String k Distance Apart 按距离为k隔离重排字符串
  2. 第一个web框架tornado
  3. 【BZOJ】3737: [Pa2013]Euler
  4. React Native 简介:用 JavaScript 搭建 iOS 应用(2)
  5. 监听某个div或其它标签的大小改变来执行相应的处理
  6. 步步为营 SharePoint 开发学习笔记系列总结
  7. 《A First Course in Abstract Algebra with Applications》-chaper1-数论
  8. CountDownLatch的使用
  9. 管理 sendmail 的邮件队列
  10. jquery 监听回车提交
  11. 65、django之模型层(model)--添加、单表查询、修改基础
  12. React Native:真机断点调试+跨域资源加载出错问题解决
  13. CentOS添加磁盘分区
  14. 在&#39;for&#39;循环中获取索引
  15. FFmpeg 学习(三):将 FFmpeg 移植到 Android平台
  16. gRPC奇怪的编译命令protoc
  17. calloc()的使用
  18. ubuntu上编译linux内核
  19. sh-copy-id命令报错:-bash: ssh-copy-id: command not found
  20. zookeeper集群搭建 windows

热门文章

  1. UVa-1339-古老的密码
  2. 【JDBC-MVC模式】开发实例
  3. rpm 包管理器
  4. Java:post请求
  5. Centos6.5安装Nexus及安装时的一些错误
  6. LeetCode01--两数之和
  7. python和shell获取命令行参数的区别
  8. 【SPOJ694&amp;705】Distinct Substrings(后缀数组)
  9. js82:CSS的Style,image的重定位,getElementById,getElementsByTagName,location.href
  10. Lca 之倍增算法