androidandroid 上下左右滑动动指引效果 如何实现

android 中类似酷狗音乐主界面中的左右拖动界面如何实现?
现在有很多APP都使用了主界面中页面切换实现了左右滑动来进行加载(实现方式应该不是ViewPager方式),而且在开始滑动的时候可以使的第一个界面显示多半,目测占屏幕的4/5,而即将要滑出进行显示的界面占1/5,再次向左滑动,第二个界面完全显示出来。看上去比较美观实用,请问如何才能实现这种效果呢?
按赞数排序
viewpager很容易完美实现,此下例子我已测试过了
其他相似问题
相关参考资料如何在Android中实现左右滑动的指引效果_百度知道
如何在Android中实现左右滑动的指引效果
提问者采纳
&nbsp.loadAnimation( & private ViewF&& & & -120) {& &nbsp, R; & & & // TODO Auto-generated method stub& &nbsp.getX() - e2; & }&& & public boolean onDown(MotionEvent e) {& &nbsp.addView(addImageView(R;& &nbsp. && & &nbsp. & &nbsp.& public void onCreate(Bundle savedInstanceState) {& &&nbsp.jpg" target="_blank" title="点击查看大图" class="ikqb_img_alink"><img class="ikqb_img" src=" & &/zhidao/wh%3D600%2C800/sign=cd79a0ac0f77a613ff5c1/728dab8b0c33dadbb4e1ee. &nbsp, float distanceX; &nbsp.getX() & &nbsp.push_right_in)), MotionEvent e2; &nbsp.& && &nbsp.five));& & // TODO Auto-generated method stub&nbsp. & &nbsp.one)); & & & &nbsp, MotionEvent e2; @Override& &nbsp.two));& & &* @File.addView(addImageView(R; & &nbsp.OnGestureListener. &nbsp. }&/zhidao/wh%3D600%2C800/sign=43c86f0e7e1ed21b799c26e39d5ef1fc/fcfaaf51f3deb48ff3a292cf578 &nbsp.getX() & & & &nbsp.baidu.three)); &nbsp.showPrevious(); @Override& @Override& float velocityY) {&nbsp.ViewFlipper.addView(addImageView(R;& && public void onLongPress(MotionEvent e) {&nbsp.java& & }& public boolean onSingleTapUp(MotionEvent e) {& & &nbsp.setOutAnimation(AnimationU&nbsp,& &nbsp.A } else if (e1; }& & & &import android.id. & public boolean onScroll(MotionEvent e1; & &nbsp.B private View addImageView(int id) {&nbsp.anim. && && & & & &nbsp.findViewById(R; }&/zhidao/wh%3D450%2C600/sign=df8966a2dec451daf6a304ef83cd7e50/fcfaaf51f3deb48ff3a292cf578 &&/zhidao/pic/item/728dab8b0c33dadbb4e1 &* @Date
上午10; &nbsp. & &nbsp. & // TODO Auto-generated method stub&& &nbsp://e.0& & & & this.GestureD&/zhidao/wh%3D450%2C600/sign=21119ac3daf9d72aab0c33dadbb4e1& public boolean onFling(MotionEvent e1; & & & @Override&nbsp.hiphotos.ViewFlipper1).& && & &nbsp.jpg" esrc="http, R;* @P & &*/public class MainActivity extends Activity implements OnGestureListener {& && & & public boolean onTouchEvent(MotionEvent event) {&nbsp, R; & &nbsp.push_left_out)). & & &nbsp.showNext(); &&nbsp://d; & &nbsp.baidu.four));& & &nbsp. & & }& & &nbsp.addView(addImageView(R; }}<a href="/**& /** Called when the activ & &nbsp. &&nbsp.onCreate(savedInstanceState).flipper. &&nbsp. & & &&&nbsp.main); // TODO Auto-generated method stub& @Override& & public void onShowPress(MotionEvent e) {& &nbsp://e; flipper = (ViewFlipper) this, float velocityX.addView(addImageView(R. & // TODO Auto-generated method stub&nbsp.V && & & }& & @Override& & &nbsp.GestureDetector. &* @Version V1; & & & & &&nbsp.&nbsp. && &nbsp.loadAnimation( &nbsp.MotionE & &nbsp.&nbsp.& & // TODO Auto-generated method stub&nbsp: return false:44; & 120) {&& &nbsp.AnimationUtils. & &nbsp.loadAnimation( & ImageView iv = new ImageView(this); &nbsp.push_right_out)); &* Android实现左右滑动效果&& && & float distanceY) {&nbsp. &nbsp.baidu.getX() - e2;& @Override& & if (e1;&&&nbsp.hiphotos.push_left_in)); &nbsp  MainActivity文件中代码.view
资深电脑人
其他类似问题
android的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁Android相关信息
?相关Android文章推荐
热门Android文章推荐
config_statusBarComponent" trans
阅读Android 4.0源码也有一段时间
最近做项目要用到IPHONE 左右滑动
属性名称 描述 android:columnWidt
SurfaceView 示波器的例子:直接上
ScrollView是一种特殊的FrameLayou
最近研究了一下Contacts源码,仿照
说到GridView Listview一定会提到
首先设置只能输入数字: [html] Ed
在android应用程序中,有时要用到
广告赞助商
Android文章阅读排
Android使用ViewFlipper实现左右滑动效果面
摘要:效果看完了就来实现这个效果。 1.布局文件 主界面使用下面的布局: ?xml version=1.0 encoding=utf-8?FrameLayout xmlns:android=/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:
效果看完了就来实现这个效果。
1.布局文件
主界面使用下面的布局:
&?xml version=&1.0& encoding=&utf-8&?&
&FrameLayout xmlns:android=&/apk/res/android&
android:layout_width=&fill_parent&
android:layout_height=&fill_parent&
android:orientation=&vertical& &
&ViewFlipper android:id=&@+id/ViewFlipper1&
android:layout_width=&fill_parent&
android:layout_height=&fill_parent&&
&/ViewFlipper&
&LinearLayout
android:orientation=&horizontal&
android:layout_width=&wrap_content&
android:layout_gravity=&bottom|center_horizontal&
android:layout_height=&wrap_content&
&ImageView
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:src=&@drawable/da&
android:id=&@+id/imageview1&
&ImageView
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:src=&@drawable/xiao&
android:id=&@+id/imageview2&
&ImageView
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:src=&@drawable/xiao&
android:id=&@+id/imageview3&
&ImageView
android:layout_width=&wrap_content&
android:layout_height=&wrap_content&
android:src=&@drawable/xiao&
android:id=&@+id/imageview4&
&/LinearLayout&
&/FrameLayout&
简单的介绍一下布局文件:最外层是一个FrameLayout,使用FrameLayout就是为了是的下面的四个点在ViewFlipper上面。LayoutLayout在FrameLayout的下面和水平居中。
2.ViewFlipper的使用
flipper = (ViewFlipper) this.findViewById(R.id.ViewFlipper1);
flipper.addView(addImageView(R.drawable.png1o));
flipper.addView(addImageView(R.drawable.png2o));
flipper.addView(addImageView(R.drawable.png3o));
flipper.addView(addView());
(原文出处:吾吾织梦)
------分隔线----------------------------
◎ 广告赞助
◎ 阅读说明READ EXPLANATION
推荐使用第三方专业下载工具下载本站软件,使用 WinRAR v3.10 以上版本解压本站软件。
本站空间有限.资源到网盘下载.谢谢&& 赞助本站(广告),联系站长QQ&&
为加快源码更新本站源码未全部调试.所以有关源码问题请到交流,讨论,
如须购买金币(升级VIP)&本站解压密码
下载本站资源,如果服务器暂不能下载请过一段时间重试!
如果遇到什么问题,请到本站论坛去咨寻,我们将在那里提供更多 、更好的资源!
本站提供的一些商业软件是供学习研究之用,如用于商业用途,请购买正版。西西软件下载最安全的下载网站、值得信赖的软件下载站!
您的位置:
→ Android开发实现qqminihd 左右滑动菜单效果
观察qqminihd界面,发现其界面能够左右滑动来实现两侧菜单效果。自定义Layout:ScrollLayout.java直接贴出代码:& 1 package grimbo.android.demo.& 2 & 3 import android.content.C& 4 import android.util.AttributeS& 5 import android.util.L& 6 import android.view.GestureD& 7 import android.view.GestureDetector.OnGestureL& 8 import android.view.MotionE& 9 import android.view.V10 import android.view.ViewC11 import android.view.animation.AnimationU12 import android.widget.LinearL13 import android.widget.S14 15 public class ScrollLayout extends LinearLayout {16 17 //&&& private static final String TAG = &scroller&;18 19&&&& private S20 21&&&& private int currentScreenI22 23&&&& private GestureDetector gestureD24 25&&&& // 设置一个标志位,防止底层的onTouch事件重复处理UP事件26&&&& p27 28&&&& /**29&&&&& * 菜单栏的宽度30&&&&& */31&&&& int menuWidth=80;32&&&& 33&&&& /**34&&&&& * 显示左边菜单35&&&&& * 否则显示右边菜单36&&&&& */37&&&& private boolean showLeft=38&&&& 39&&&& /**40&&&&& * 滚出边界监听器41&&&&& */42&&&& private OnScrollSideChangedListener scrollSideChangedL43&&&& 44&&&& public Scroller getScroller() {45&&&&&&&&&&&&46&&&& }47 48&&&& public OnScrollSideChangedListener getScrollSideChangedListener() {49&&&&&&&& return scrollSideChangedL50&&&& }51 52&&&& public void setScrollSideChangedListener(53&&&&&&&&&&&& OnScrollSideChangedListener scrollSideChangedListener) {54&&&&&&&& this.scrollSideChangedListener = scrollSideChangedL55&&&& }56 57&&&& public ScrollLayout(Context context, AttributeSet attrs) {58&&&&&&&&&&&& super(context, attrs);59&&&&&&&&&&&& initView(context);60&&&& }61 62&&&& public ScrollLayout(Context context) {63&&&&&&&&&&&& super(context);64&&&&&&&&&&&& initView(context);65&&&& }66 67&&&& private void initView(final Context context) {68&&&&&&&&&&&& this.scroller = new Scroller(context,AnimationUtils.loadInterpolator(context,69&&&&&&&&&&&&&&&&&&&& android.R.anim.overshoot_interpolator));70 71&&&&&&&&&&&& this.gestureDetector = new GestureDetector(new OnGestureListener() {72 73&&&&&&&&&&&&&&&&&&&& @Override74&&&&&&&&&&&&&&&&&&&& public boolean onSingleTapUp(MotionEvent e) {75&&&&&&&&&&&&&&&&&&&&&&&&&&&&76&&&&&&&&&&&&&&&&&&&& }77 78&&&&&&&&&&&&&&&&&&&& @Override79&&&&&&&&&&&&&&&&&&&& public void onShowPress(MotionEvent e) {80&&&&&&&&&&&&&&&&&&&& }81 82&&&&&&&&&&&&&&&&&&&& @Override83&&&&&&&&&&&&&&&&&&&& public boolean onScroll(MotionEvent e1, MotionEvent e2,84&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& float distanceX, float distanceY) {85 86&&&&&&&&&&&&&&&&&&&&&&&&&&&& {// 防止向第一页之前移动87&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& if(1==currentScreenIndex)88&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& {89&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& int screenLeft=getWidth()-menuW90&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& if(showLeft && getScrollX()&screenLeft)91&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& {92&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& showLeft=93 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Log.e(&TAG&,&显示右边菜单栏&);94&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& if(null!=scrollSideChangedListener)95&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& scrollSideChangedListener.onScrollSideChanged(ScrollLayout.this, showLeft);96&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& }97&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& else if(!showLeft && getScrollX()&screenLeft)98&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& {99&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& showLeft=100 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Log.e(&TAG&,&显示左边菜单栏&);101&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& if(null!=scrollSideChangedListener)102&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& scrollSideChangedListener.onScrollSideChanged(ScrollLayout.this, showLeft);103&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& }104&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& }105&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 106&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& fling =107&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& scrollBy((int) distanceX, 0);108 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Log.d(&TAG&, &on scroll&&&&&&&&&&&&&&&&&移动&&&&&&&&&&&&&&&&&&);109&&&&&&&&&&&&&&&&&&&&&&&&&&&& }110&&&&&&&&&&&&&&&&&&&&&&&&&&&&111&&&&&&&&&&&&&&&&&&&& }112 113&&&&&&&&&&&&&&&&&&&& @Override114&&&&&&&&&&&&&&&&&&&& public void onLongPress(MotionEvent e) {115&&&&&&&&&&&&&&&&&&&& }116 117&&&&&&&&&&&&&&&&&&&& @Override118&&&&&&&&&&&&&&&&&&&& public boolean onFling(MotionEvent e1, MotionEvent e2,119&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& float velocityX, float velocityY) {120&&&&&&&&&&&&&&&&&&&&&&&& 121&&&&&&&&&&&&&&&&&&&&&&&&&&&& if (Math.abs(velocityX) & ViewConfiguration.get(context)122&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& .getScaledMinimumFlingVelocity()) 123&&&&&&&&&&&&&&&&&&&&&&&&&&&& {// 判断是否达到最小轻松速度,取绝对值的124&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& fling =125&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& snapToDestination();126 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Log.d(TAG, &on scroll&&&&&&&&&&&&&&&&&滑动&&&&&&&&&&&&&&&&&&);127&&&&&&&&&&&&&&&&&&&&&&&&&&&& }128 129&&&&&&&&&&&&&&&&&&&&&&&&&&&&130&&&&&&&&&&&&&&&&&&&& }131 132&&&&&&&&&&&&&&&&&&&& @Override133&&&&&&&&&&&&&&&&&&&& public boolean onDown(MotionEvent e) {134&&&&&&&&&&&&&&&&&&&&&&&&&&&&135&&&&&&&&&&&&&&&&&&&& }136&&&&&&&&&&&& });137&&&&&&&&&&&& 138&&&& }139&&&& //每一个屏的边界值140&&&& //0----[getWidth()-20]----[2*getWidth()-20]-----[3*getWidth()-40]141&&&& 142&&&& 143&&&& @Override144&&&& protected void onLayout(boolean changed, int left, int top, int right,145&&&&&&&&&&&&&&&&&&&& int bottom) {146&&&&&&&&&&&& /**147&&&&&&&&&&&&& * 设置布局,将子视图顺序横屏排列148&&&&&&&&&&&&& */149&&&&&&&&&&&& super.onLayout(changed, left, top, right, bottom);150&&&&&&&&&&&& int move=getWidth()-menuW151&&&&&&&&&&&& for (int i = 0; i & getChildCount(); i++) 152&&&&&&&&&&&& {153&&&&&&&&&&&&&&&&&&&& View child = getChildAt(i);154 //&&&&&&&&&&&&&&&&&&& child.setVisibility(View.VISIBLE);155&&&&&&&&&&&&&&&&&&&& //移动一定的距离156&&&&&&&&&&&&&&&&&&&& child.layout(child.getLeft()+move,child.getTop(),child.getRight()+move,child.getBottom());157&&&&&&&&&&&& }158&&&& }159 160&&&& @Override161&&&& public void computeScroll() {162&&&&&&&&&&&& if (puteScrollOffset()) {163 //&&&&&&&&&&&&&&&&&&& Log.d(TAG, &&&&&&&&&&&computeScroll&&&&&&+scroller.getCurrX());164&&&&&&&&&&&&&&&&&&&& scrollTo(scroller.getCurrX(), 0);165&&&&&&&&&&&&&&&&&&&& postInvalidate();166&&&&&&&&&&&& }167&&&& }168 169&&&& @Override170&&&& public boolean onTouchEvent(MotionEvent event) {171&&&&&&&&&&&& 172&&&&&&&&&&&& float x2s=getScrollX()+event.getX();173&&&&&&&&&&&& 174&&&&&&&&&&&& if(x2s&getWidth()-menuWidth || x2s&2*getWidth()-menuWidth)175&&&&&&&&&&&& {//动作在区域外面176&&&&&&&&&&&&&&&& if(!fling)//没有在滑动177&&&&&&&&&&&&&&&& {178 //&&&&&&&&&&&&&&&&&&& Log.d(TAG, &on scroll&&&&&&&&&&&&&&&&&动作在区域外面 没有在滑动&&&&&&&&&&&&&&&&&&);179&&&&&&&&&&&&&&&&&&&&180&&&&&&&&&&&&&&&& }181&&&&&&&&&&&&&&&& else if(MotionEvent.ACTION_UP!=event.getAction())182&&&&&&&&&&&&&&&& {//否则如果也不是抬起手势,则强制模拟抬起183&&&&&&&&&&&&&&&&&&&& snapToDestination();184&&&&&&&&&&&&&&&&&&&& fling =185 //&&&&&&&&&&&&&&&&&&& Log.d(TAG, &on scroll&&&&&&&&&&&&&&&&&动作在区域外面 在滑动 也不是抬起手势&&&&&&&&&&&&&&&&&&);186&&&&&&&&&&&&&&&&&&&&187&&&&&&&&&&&&&&&& }188 //&&&&&&&&&&&&&&& Log.e(TAG, &on scroll&&&&&&&&&&&&&&&&&动作在区域外面 在滑动 是抬起手势&&&&&&&&&&&&&&&&&&);189&&&&&&&&&&&& }190&&&&&&&&&&&& 191&&&&&&&&&&&& gestureDetector.onTouchEvent(event);192 193&&&&&&&&&&&& switch (event.getAction()) {194&&&&&&&&&&&& case MotionEvent.ACTION_DOWN:195&&&&&&&&&&&&&&&&&&&&196&&&&&&&&&&&& case MotionEvent.ACTION_MOVE:197&&&&&&&&&&&&&&&&&&&&198&&&&&&&&&&&& case MotionEvent.ACTION_UP:199 //&&&&&&&&&&&&&&&&&&& Log.d(TAG, &&&ACTION_UP:&&&&&&&& MotionEvent.ACTION_UP&&&&&&);200 //&&&&&&&&&&&&&&&&&&& if (!fling) 201&&&&&&&&&&&&&&&&&&&& {202&&&&&&&&&&&&&&&&&&&&&&&&&&&& snapToDestination();203&&&&&&&&&&&&&&&&&&&& }204&&&&&&&&&&&&&&&&&&&& fling =205&&&&&&&&&&&&&&&&&&&&206&&&&&&&&&&&& default:207&&&&&&&&&&&&&&&&&&&&208&&&&&&&&&&&& }209&&&&&&&&&&&&210&&&& }211 212&&&& /**213&&&&& * 切换到指定屏214&&&&& * 215&&&&& * @param whichScreen216&&&&& */217&&&& public void scrollToScreen(int whichScreen) {218&&&&&&&&&&&& if (getFocusedChild() != null && whichScreen != currentScreenIndex219&&&&&&&&&&&&&&&&&&&&&&&&&&&& && getFocusedChild() == getChildAt(currentScreenIndex)) {220&&&&&&&&&&&&&&&&&&&& getFocusedChild().clearFocus();221&&&&&&&&&&&& }222&&&&&&&&&&&& int delta = 0;223&&&&&&&&&&&& 224&&&&&&&&&&&& if(whichScreen==0)225&&&&&&&&&&&&&&&& delta= - getScrollX();226&&&&&&&&&&&& else if(whichScreen==1)227&&&&&&&&&&&&&&&& delta= getWidth()-menuWidth- getScrollX();228&&&&&&&&&&&& else if(whichScreen==2)229&&&&&&&&&&&&&&&& delta= 2*(getWidth()-menuWidth)- getScrollX();230&&&&&&&&&&&& else231&&&&&&&&&&&&&&&&232 //&&&&&&&&&&&&&&& delta = whichScreen * getWidth() - getScrollX();233&&&&&&&&&&&& 234&&&&&&&&&&&& scroller.startScroll(getScrollX(), 0, delta, 0, Math.abs(delta) * 2);235&&&&&&&&&&&& invalidate();236 237&&&&&&&&&&&& currentScreenIndex = whichS238&&&& }239 240&&&& /**241&&&&& * 根据当前x坐标位置确定切换到第几屏242&&&&& */243&&&& private void snapToDestination() {244&&&&&&&& 245&&&&&&&& if(getScrollX()&(getWidth()-menuWidth)/2)246&&&&&&&&&&&& scrollToScreen(0);247&&&&&&&& else if(getScrollX()&(getWidth()-menuWidth+getWidth()/2))248&&&&&&&&&&&& scrollToScreen(1);249&&&&&&&& else250&&&&&&&&&&&& scrollToScreen(2);251&&&& }252 253&&&& public interface OnScrollSideChangedListener254&&&& {255&&&&&&&& public void onScrollSideChanged(View v,boolean leftSide);256&&&& }257 }接下来,在定义activity里面的布局my_layout.xml:1 &?xml version=&1.0& encoding=&utf-8&?&2 &FrameLayout xmlns:android=&/apk/res/android&3&&&& xmlns:app=&/apk/res/grimbo.android.demo.slidingmenu&4&&&& android:id=&@+id/FrameLayout1&5&&&& android:layout_width=&match_parent&6&&&& android:layout_height=&match_parent& &7&&&& &LinearLayout8&&&&&&&& android:layout_width=&match_parent&9&&&&&&&& android:layout_height=&match_parent&10&&&&&&&& android:id=&@+id/left_menu&11&&&&&&&& android:background=&#333&12&&&&&&&& android:orientation=&vertical& &13 14&&&&&&&& &Button15&&&&&&&&&&&& android:layout_width=&200dp&16&&&&&&&&&&&& android:layout_height=&wrap_content&17&&&&&&&&&&&& android:text=&左菜单一& /&18&&&&&&&& &Button19&&&&&&&&&&&& android:layout_width=&200dp&20&&&&&&&&&&&& android:layout_height=&wrap_content&21&&&&&&&&&&&& android:text=&左菜单二& /&22&&&& &/LinearLayout&23 24&&&& &LinearLayout25&&&&&&&& android:id=&@+id/right_menu&26&&&&&&&& android:layout_width=&match_parent&27&&&&&&&& android:layout_height=&match_parent&28&&&&&&&& android:background=&#666&29&&&&&&&& android:orientation=&horizontal& &30&&&&&&&& &LinearLayout31&&&&&&&&&&&& android:layout_width=&wrap_content&32&&&&&&&&&&&& android:layout_height=&wrap_content&33&&&&&&&&&&&& android:layout_weight=&1&34&&&&&&&&&&&& android:orientation=&vertical& &35&&&&&&&& &/LinearLayout&36&&&&&&&& &LinearLayout37&&&&&&&&&&&& android:layout_width=&200dp&38&&&&&&&&&&&& android:layout_height=&wrap_content&39&&&&&&&&&&&& android:orientation=&vertical& &40&&&&&&&&&&&& &Button41&&&&&&&&&&&&&&&& android:layout_width=&match_parent&42&&&&&&&&&&&&&&&& android:layout_height=&wrap_content&43&&&&&&&&&&&&&&&& android:text=&右菜单一& /&44&&&&&&&&&&&& &Button45&&&&&&&&&&&&&&&& android:layout_width=&match_parent&46&&&&&&&&&&&&&&&& android:layout_height=&wrap_content&47&&&&&&&&&&&&&&&& android:text=&右菜单二& /&48&&&&&&&&&&&& 49&&&&&&&& &/LinearLayout&50&&&&&&&& 51&&&& &/LinearLayout&52&&&& &grimbo.android.demo.slidingmenu.ScrollLayout53&&&&&&&& android:layout_width=&match_parent&54&&&&&&&& android:orientation=&vertical&55&&&&&&&& android:id=&@+id/my_scrollLayout&56&&&&&&&& android:layout_height=&match_parent&&57&&&&&&&& &LinearLayout58&&&&&&&&&&&& android:layout_width=&match_parent&59&&&&&&&&&&&& android:layout_height=&match_parent&60&&&&&&&&&&&& android:background=&#aaa&61&&&&&&&&&&&& android:orientation=&vertical& &62 63 64&&&&&&&&&&&& &Button65&&&&&&&&&&&&&&&& android:id=&@+id/button1&66&&&&&&&&&&&&&&&& android:layout_width=&match_parent&67&&&&&&&&&&&&&&&& android:layout_height=&wrap_content&68&&&&&&&&&&&&&&&& android:text=&Button Button& /&69 70&&&&&&&&&&&& &Spinner71&&&&&&&&&&&&&&&& android:id=&@+id/spinner1&72&&&&&&&&&&&&&&&& android:layout_width=&match_parent&73&&&&&&&&&&&&&&&& android:layout_height=&wrap_content& /&74 75&&&&&&&&&&&& &SeekBar76&&&&&&&&&&&&&&&& android:id=&@+id/seekBar1&77&&&&&&&&&&&&&&&& android:layout_width=&match_parent&78&&&&&&&&&&&&&&&& android:layout_height=&wrap_content& /&79&&&&&&&&&&&& 80&&&&&&&& &/LinearLayout&81 82&&&& &/grimbo.android.demo.slidingmenu.ScrollLayout&83&&&& 84 &/FrameLayout&最后,在activity里面的onCreate函数里加上: 1 setContentView(R.layout.my_layout);
final LinearLayout left=(LinearLayout)findViewById(R.id.left_menu);
final LinearLayout right=(LinearLayout)findViewById(R.id.right_menu);
right.setVisibility(View.GONE);
left.setVisibility(View.VISIBLE);
ScrollLayout mScrollLayout=(ScrollLayout)findViewById(R.id.my_scrollLayout);
mScrollLayout.setScrollSideChangedListener(new OnScrollSideChangedListener() {
public void onScrollSideChanged(View v, boolean leftSide) {
if(leftSide)
right.setVisibility(View.GONE);
left.setVisibility(View.VISIBLE);
right.setVisibility(View.VISIBLE);
left.setVisibility(View.GONE);
});大功告成!左右滑动是弹性效果也一并实现~
阅读本文后您有什么感想? 已有
人给出评价!
访问量多的

我要回帖

更多关于 android左右滑动事件 的文章

 

随机推荐