- 0
- 0
- 约1.58万字
- 约 8页
- 2017-08-15 发布于江苏
- 举报
工程中需要这样的效果,左边和右边的Panel可以打开关闭:
我把左边和右边的Panel封装成2个类了。这里要特别注意,抽屉是需要“handler” 的,我这里可以把任何View都
看成“handler” ,使用setBindView(View bindView)方法进行绑定“handler” 。这样做的好处是“把手”可以独立于抽
屉,可以任意控制把手的位置,而不需要把手跟着抽屉移动!
先看左边的Panel:
Java代 码
1. import android.content.Context;
2. import android.os.AsyncTask;
3. import android.view.View;
4. import android.widget.LinearLayout;
5.
6. public class LeftPanel extends LinearLayout{
7.
8. /**每次 自动展开/收缩 的范 围*/
9. private final static int SPEED=20;
10. private int MAX_WIDTH=0;
11. private Context mContext;
12.
13. public LeftPanel(Context context,int width,int height) {
14. super(context);
15. this.mContext=context;
16. //设置 Panel本身 的属性
17. LayoutParams lp=new LayoutParams(width, height);
18. lp.leftMargin=-lp.width;
19. MAX_WIDTH=Math.abs(lp.leftMargin);
20. this.setLayoutParams(lp);
21. }
22. /**
23. *
24. * @param context
25. * @param width
26. * @param height
27. * @param bindView
28. * @param contentView
29. */
30. public LeftPanel(Context context,int width,int height,View bindView,View contentView)
{
31. this(context,width,height);
32. setBindView(bindView);
33. setContentView(contentView);
34. }
35. /**
36. * 把View放在 Panel中
37. * @param v
38. */
39. public void setContentView(View v){
40. this.addView(v);
41. }
42.
43. /**
44. * 绑定触发动画 的View
45. * @param bindView
46. */
47. public void setBindView(View bindView){
48. bindView.setOnClickListener(new OnClickListener(){
49.
50. @Override
51.
您可能关注的文档
- 健康饮食的PPT演讲-1.ppt
- 傍l勒雪氏综合征临床分析.pdf
- 傍人门户的成语故事.pdf
- 傍晚A班练习.doc
- 傍晚跳跳舞,活动身子骨.doc
- 傍海而居,醉在大理.pdf
- 傍热点叫卖“杭州湾大桥”*商标一 20万元无人问津.doc
- 傍针刺法临床应用举隅.pdf
- 催乳师的未来发展.pdf
- 傲不可长(励志文章).doc
- GB/T 42818.2-2026认知无障碍 第2部分:报告.pdf
- 中国国家标准 GB/T 47116-2026地下采矿机械 工作面移动式采掘机械 采煤机和犁式系统的安全要求.pdf
- 《GB/T 47116-2026地下采矿机械 工作面移动式采掘机械 采煤机和犁式系统的安全要求》.pdf
- 中国国家标准 GB/T 42818.2-2026认知无障碍 第2部分:报告.pdf
- 《GB/T 42818.2-2026认知无障碍 第2部分:报告》.pdf
- 《GB/T 27664.1-2026无损检测仪器 超声检测设备的性能与检验 第1部分:仪器》.pdf
- 中国国家标准 GB/T 27664.1-2026无损检测仪器 超声检测设备的性能与检验 第1部分:仪器.pdf
- GB/T 27664.1-2026无损检测仪器 超声检测设备的性能与检验 第1部分:仪器.pdf
- GB/T 45305.5-2026声学 建筑构件隔声的实验室测量 第5部分:测试设施和设备的要求.pdf
- 中国国家标准 GB/T 45305.5-2026声学 建筑构件隔声的实验室测量 第5部分:测试设施和设备的要求.pdf
原创力文档

文档评论(0)