Imitating the effect of the tile where it is going, imitating the effect of the tile

Source: Internet
Author: User

Imitating the effect of the tile where it is going, imitating the effect of the tile

I feel that the page where I go is doing very well and very nice. So I want to imitate it. In fact, the implementation is very simple, that is, to press down the animation and lift it back to normal, this effect is called the tile effect. As the name suggests, it feels the same as the tile. Let's take a look:


Next let's take a look at the most important custom code:

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 isPress Ed; private ScaleAnimation zoomInAnimation; private ScaleAnimation attributes; public HomeMenuButton (Context context) {this (context, null);} public HomeMenuButton (Context context, AttributeSet attrs) {super (context, attrs); init () ;}@ Overrideprotected void onMeasure (int widthMeasureSpec, int heightMeasureSpec) {super. onMeasure (widthMeasureSpec, heightMeasureSpec);} private void init () {/*** initialize the animation * /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 ;} @ Overridepublic boolean onTouchEvent (MotionEvent event) {switch (event. ge TAction () {case MotionEvent. ACTION_DOWN: isPressed = true; // set trueinvalidate (); // re-paint this. startAnimation (zoomInAnimation); // execute the animation break; case MotionEvent. ACTION_UP: boolean need1_mclick = isPressed; toNormalState (); // normal if (need1_mclick) {1_mclick ();} 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 ;}}
The above code is almost completed at night: you only need to write the custom code in XML:

<?xml version="1.0" encoding="utf-8"?><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. All done. The effect can also be: Haha



:







Where did Dad go in this issue? Tian Liang imitates others' dads.

@ Don't lose weight many years on the 20th floor, the house where everyone was gloated and said that four five fathers and daughters were assigned to the strawberry room. Only he said that we were falling into the rocks. It's not suitable. It looks very sincere. I was moved, and then I sent my grandmother's doll as soon as the sun was leaving. My grandmother ran out of tears while holding the doll. --------------------------- what was the son dish's doll? I have never seen this ......!!!! Which segment does QAQ belong?
 
Windows 7 desktop beautification software can imitate win8 tile interface?

First, give you an irresponsible link: www.oyksoft.com/soft/18912.html
This is obtained directly and is difficult to use.
In addition, I would like to give you some good suggestions. Download a magic cube optimization master and go to IT home. There are many win7 beautification themes in this forum. you can install them after using the magic cube to crack the win7 theme, I don't know whether there are any tile themes, but there are a lot of beautiful and generous themes. To be honest, if you don't have win8, just install a tile, it will look ugly, win8 is beautiful, with metro-based tile and animation matching. Correspondingly, the aero of Windows 7 can also be very beautiful, and the browser cannot send a picture. Otherwise, I will show you my computer theme. There is no major change, but it is still very comfortable to look.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.