extends LinearLayout 实现侧滑菜单
来源:互联网 发布:a站ceo莫然离职 知乎 编辑:程序博客网 时间:2024/05/21 09:50
package com.ce.MyLayout;import android.content.Context;import android.util.AttributeSet;import android.widget.LinearLayout;import android.widget.Scroller;public class SlideLinearLayout extends LinearLayout {private boolean ishow = false;private Scroller mScroller = null;private int distance;public SlideLinearLayout(Context context, AttributeSet attrs) {super(context, attrs);mScroller = new Scroller(context);// TODO Auto-generated constructor stub}@Overridepublic void computeScroll() {if (mScroller.computeScrollOffset()) {if (ishow) {scrollTo(mScroller.getCurrX(), 0);} else {scrollTo(mScroller.getCurrX() - distance, 0);}postInvalidate();}}public void beginScroll(Boolean isShow, int odistance,int duration) {distance=odistance;if (!ishow) {mScroller.startScroll(0, 0, -distance, 0, duration);ishow = true;} else {mScroller.startScroll(0, 0, distance, 0, duration);ishow = false;}invalidate();}public boolean Ishow() {return ishow;}}
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="scroll" android:onClick="scroll" /> <com.wb.SlideLinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/myviewGroup"> <TextView android:layout_width="wrap_content" android:layout_height="fill_parent" android:background="#ff0000" android:text="我在這"/> </com.wb.SlideLinearLayout> </FrameLayout>
要点:
1 FrameLayout布局的特性
2 对以下方法的理解:
2.1 Override computeScroll()
2.2 Scroller 0 0
- extends LinearLayout 实现侧滑菜单
- Android中listview extends Linearlayout
- Android自定义LinearLayout实现左右侧滑菜单,完美兼容ListView、ScrollView、ViewPager等滑动控件
- 两个LinearLayout实现简单的菜单增加和删除
- LinearLayout + TextView 树形菜单
- 【Android】自定义LinearLayout实现侧滑布局--SwipeLinearLayout
- Android滑动菜单特效实现,侧滑菜单实现
- 侧滑菜单的实现
- Android 侧滑菜单实现
- android 侧滑菜单 实现
- android 侧滑菜单实现
- HorizontalScrollView实现侧滑菜单
- iOS侧滑菜单实现
- android 实现侧滑菜单
- android实现侧滑菜单
- Android侧滑菜单实现
- Android侧滑菜单实现
- iOS侧滑菜单实现
- 2dx游戏开发简单笔记
- ubuntu上安装nasm以及nasm在ubuntu上的简单使用
- 函数指针在MFC中的应用
- 坐等过大年的我之腊月23唠叨
- 构建基于OSGi.NET的ASP.NET Web插件应用程序(上)
- extends LinearLayout 实现侧滑菜单
- UDX对多网络设备支持,视频会议中单兵设备的多3G网卡支持
- Oracle创建自增字段方法-ORACLE SEQUENCE的简单介绍
- VB问题
- 翻译A Multiscale Retinex for Bridging the Gap Between Color Images and the Human Observation of Scenes
- Android 根据角度旋转图片
- oracle hints (摘录)
- Linux进程退出码
- windows编程——编译及向导安装