日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > 互聯網 > 模仿去哪兒的磁貼效果

模仿去哪兒的磁貼效果

來源:程序員人生   發布時間:2014-11-14 08:38:32 閱讀次數:3330次

感覺去哪兒的頁面做的非常不錯,非常好看,因而想模仿1下,其實實現還是很簡單的,就是按下去的履行縮小動畫,抬起的恢復正常狀態,這類效果叫磁貼效果,顧名思義感覺就磁貼1樣。下面我們來看看效果圖:


下面我們來看看最重要的自定義代碼:

package com.zqy.qunertext; import android.content.Context; import android.graphics.Canvas; import android.util.AttributeSet; import android.util.TypedValue; import android.view.MotionEvent; import android.view.animation.Animation; import android.view.animation.ScaleAnimation; import android.widget.FrameLayout; /** * * * @author zqy * */ public class HomeMenuButton extends FrameLayout { private boolean isPressed; private ScaleAnimation zoomInAnimation; private ScaleAnimation zoomOutAnimation; public HomeMenuButton(Context context) { this(context,null); } public HomeMenuButton(Context context, AttributeSet attrs) { super(context, attrs); init(); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } private void init() { /** * 初始化動畫 */ zoomInAnimation = new ScaleAnimation(1f, 0.95f, 1f, 0.95f,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f); zoomInAnimation.setFillAfter(true); zoomInAnimation.setDuration(200); zoomOutAnimation = new ScaleAnimation(0.95f, 1f, 0.95f, 1f,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f); zoomOutAnimation.setFillAfter(true); zoomOutAnimation.setDuration(200); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); } private void toNormalState() { isPressed = false; invalidate(); startAnimation(zoomOutAnimation); } private boolean pointInView(float localX, float localY, float slop) { return localX >= -slop && localY >= -slop && localX < getWidth() + slop && localY < getHeight() + slop; } @Override public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: isPressed = true;//設置true invalidate();//重繪 this.startAnimation(zoomInAnimation);//履行動畫 break; case MotionEvent.ACTION_UP: boolean needPerformClick = isPressed; toNormalState();//正常 if (needPerformClick) { performClick(); } break; case MotionEvent.ACTION_MOVE: final int x = (int) event.getX(); final int y = (int) event.getY(); if (!pointInView(x, y, 20)) { toNormalState(); } break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_OUTSIDE: toNormalState(); break; } return true; } }
上面代碼晚上幾近就已完成了:只有把自定義的代碼寫在XML里面就能夠了:

<?xml version="1.0" encoding="utf⑻"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:baselineAligned="false" android:orientation="horizontal" > <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginBottom="8dp" android:layout_marginLeft="8dp" android:layout_marginTop="8dp" android:layout_weight="1" android:orientation="vertical" > <com.zqy.qunertext.HomeMenuButton android:id="@+id/hb_ad" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="2" android:background="@drawable/icon_favoable" > </com.zqy.qunertext.HomeMenuButton> <com.zqy.qunertext.HomeMenuButton android:id="@+id/hb_order" android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginTop="8dp" android:layout_weight="2" android:background="@drawable/icon_order" > </com.zqy.qunertext.HomeMenuButton> <com.zqy.qunertext.HomeMenuButton android:id="@+id/hb_cloud_manger" android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginTop="8dp" android:layout_weight="1" android:background="@drawable/icon_favorable_manger" > </com.zqy.qunertext.HomeMenuButton> <com.zqy.qunertext.HomeMenuButton android:id="@+id/hb_setting" android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginTop="8dp" android:layout_weight="1" android:background="@drawable/icon_setting" > </com.zqy.qunertext.HomeMenuButton> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginBottom="8dp" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:layout_marginTop="8dp" android:layout_weight="1" android:orientation="vertical" > <com.zqy.qunertext.HomeMenuButton android:id="@+id/hb_goods_manager" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@drawable/icon_goods" > </com.zqy.qunertext.HomeMenuButton> <com.zqy.qunertext.HomeMenuButton android:id="@+id/hb_store_net" android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginTop="8dp" android:layout_weight="2" android:background="@drawable/icon_store" > </com.zqy.qunertext.HomeMenuButton> <com.zqy.qunertext.HomeMenuButton android:id="@+id/hb_incoming" android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginTop="8dp" android:layout_weight="2" android:background="@drawable/icon_money" > </com.zqy.qunertext.HomeMenuButton> <com.zqy.qunertext.HomeMenuButton android:id="@+id/hb_employee_manager" android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginTop="8dp" android:layout_weight="1" android:background="@drawable/icon_manage" > </com.zqy.qunertext.HomeMenuButton> </LinearLayout> </LinearLayout> </LinearLayout>
OK.大功告成。效果還可以:呵呵



下載地址:






生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 在线观看www | 欧美激情一区二区三区 | 成人福利在线观看 | 久久久久国产精品免费免费搜索 | 久久两性网 | 三级毛片a | 国产美女永久免费 | 久久久精品一区二区三区 | 国产精彩av | 色综合久久久 | 欧美日韩视频一区二区三区 | 91国产精品 | 精品一区二区三区在线观看国产 | 黄色高清美女免费网站 | 国产一区二区久久精品 | 亚洲成人精品一区 | 男女网站在线观看 | 日韩欧美大片 | 国产精品国产亚洲精品看不卡15 | 亚洲不卡中文字幕 | 国产精品日韩欧美 | 国产一区二区视频在线 | 日韩精品电影 | 久久电影国产免费久久电影 | av中文字幕在线观看 | 精品无码久久久久国产 | 欧美一区二区三区在线观看视频 | 在线成人精品国产区免费 | 日韩一区二区在线免费观看 | 黄色一级视频 | 日韩福利一区二区 | 中文字幕在线观看不卡 | 性疯狂做受xxxx高清视频 | 日韩天堂 | 一区免费 | 伊人久久在线 | 欧美日韩一区二区电影 | 亚洲一区二区视频在线 | 毛片av在线 | 五月婷久久 | 一本亚洲|