High imitation mobile phone QQ5.0 interface framework, high imitation qq5.0 framework

Source: Internet
Author: User

High imitation mobile phone QQ5.0 interface framework, high imitation qq5.0 framework

From an objective perspective, this mobile QQ update is still quite simple, with custom controls and great changes to the interface, however, the most important frame is its left and right sliding mechanism. Let's take a look at its effect.

We can see that it is a sliding menu method from left to right. The most important thing is the implementation of this control class. There are no major problems with other ideas. Let's take a look at how this effect can be achieved.

First, analyze how this effect is achieved. I have carefully read these points.

1: The menu appears with a magnified effect and an apha effect.

2: The main content panel is a scaled animation.

3: You can see the border distance between the menu and the main content panel. I took 1/4. It should be correct here.

4: You should also note the event shielding of the listview controls.

These are the main problems.

Next I will explain how to implement this slide pager to the code implementation.

Package com. edsheng. view; import android. animation. objectAnimator; import android. animation. propertyValuesHolder; import android. content. context; import android. util. attributeSet; import android. view. motionEvent; import android. view. view; import android. widget. relativeLayout; import android. widget. toast;/*** @ version 1.0 * @ FielName: DragPager. java * @ Date: 2014/8/5 * @ author edsheng */public class Drag Pager extends RelativeLayout {private View mMenu; // menu private View mContent; // content View private int mStartx = 0; // click Start private float mContentStartTransX = 0; // In the content view, click the sliding distance from private float mMenuStartTransX = 0; // click the sliding distance from private int DEFAULT_RIGHT_MARGIN = getResources (). getDisplayMetrics (). widthPixels/4; // The distance between the menu and the boundary is 1/4. The screen is ObjectAnimator mContent_animator; // The ObjectAnimator mMenu_animator of the content view animation ;// Menu animation private boolean misDrag = false; // whether to drag final int DEFALT_DRAG_DISTENCE = 40; // The default value of sliding is public DragPager (Context context) {super (context );} public DragPager (Context context, AttributeSet attrs, int defStyle) {super (context, attrs, defStyle);} public DragPager (Context context, AttributeSet attrs) {super (context, attrs);} public void setMenu (View menu) {mMenu = menu; LayoutParams layoutParams = ne W LayoutParams (LayoutParams. MATCH_PARENT, LayoutParams. MATCH_PARENT); layoutParams. rightMargin = DEFAULT_RIGHT_MARGIN; addView (menu, layoutParams); mMenu. setScaleY (0.75f); // initialize mMenu as high as Y to 0.75. setTranslationX (-DEFAULT_RIGHT_MARGIN * 3); // The distance from the initialization menu to-Y} public void setContent (View content) {mContent = content; addView (content );} /*** calculate the sliding position of the current MenuX ** @ param distence * @ return */private float getMenuDragX (Float distence) {float newX = distence + mMenuStartTransX; if (newX <=-DEFAULT_RIGHT_MARGIN * 3) {newX =-DEFAULT_RIGHT_MARGIN * 3;} else if (newX> = 0) {newX = 0;} return newX;}/*** calculates the sliding position of content view X ** @ param distence * @ return */private float getContentDragX (float distence) {float newX = distence + mContentStartTransX; if (newX <= 0) {newX = 0;} else if (newX> = mContent. getWidth ()-DEFAULT_RIGHT _ MARGIN) {newX = mContent. getWidth ()-DEFAULT_RIGHT_MARGIN;} return newX;}/*** stop animation */private void stopAnimation () {if (mContent_animator! = Null & mMenu_animator! = Null) {mContent_animator.cancel (); mMenu_animator.cancel () ;}// move private void move (float distence) {float nowx = getContentDragX (distence); if (nowx! = MContent. getTranslationX () {mContent. setTranslationX (nowx); float scale = nowx/(mContent. getWidth ()-DEFAULT_RIGHT_MARGIN); // calculate that the alph range is 0-1mContent.setScaleY (1-scale * 0.25f); // Y of the Content Scales mMenu. setTranslationX (getMenuDragX (distence); // set the distance from the menu to mMenu. setScaleY (0.75f + scale * 0.25f); // you can specify Y to scale mMenu. setAlpha (scale); // menu Alpha }}@ Overridepublic boolean dispatchTouchEvent (MotionEvent ev) {switch (Ev. getAction () {case MotionEvent. ACTION_DOWN: stopAnimation (); // stop the animation mStartx = (int) ev. getRawX (); // get Click to initialize xif (mContent! = Null) mContentStartTransX = mContent. getTranslationX (); // get the initialization xif (mMenu! = Null) mMenuStartTransX = mMenu. getTranslationX (); break; case MotionEvent. ACTION_MOVE: // if (Math. abs (ev. getRawX ()-mStartx)> DEFALT_DRAG_DISTENCE) {misDrag = true;} break; case MotionEvent. ACTION_UP: misDrag = false; break;} return super. dispatchTouchEvent (ev) ;}@ Overridepublic boolean onInterceptTouchEvent (MotionEvent ev) {if (misDrag) {return true; // No downstream distribution has been intercepted} else {return false; // send the event to the subview for processing and distribute it through the dispatch of the subview.} @ Overridepublic boolean onTouchEvent (MotionEvent event) {if (event. getActionIndex ()> 1) return true; switch (event. getAction () {case MotionEvent. ACTION_DOWN: return true; // consume this event so that it does not pass the case MotionEvent. ACTION_MOVE: float distence = event. getRawX ()-mStartx; // process the move (distence); break; case MotionEvent. ACTION_UP: case MotionEvent. ACTION_CANCEL: toggle (); // window rebound break;} return super. onTouchEvent (event);}/*** rebound animation */private void toggle () {if (mContent. getTranslationX ()> DEFAULT_RIGHT_MARGIN * 2) {// right animation // first, the content animation PropertyValuesHolder content_transani = PropertyValuesHolder. ofFloat ("translationX", mContent. getTranslationX (), mContent. getWidth ()-DEFAULT_RIGHT_MARGIN); PropertyValuesHolder content_ScaleY = PropertyValuesHolder. ofFloat ("scaleY", mContent. getScaleY (), 0.75f); mContent_animator = ObjectAnimator. ofPropertyValuesHolder (mContent, content_transani, content_ScaleY); mContent_animator.start (); // The Menu animation PropertyValuesHolder menu_transani = PropertyValuesHolder. ofFloat ("translationX", mMenu. getTranslationX (), 0); PropertyValuesHolder menu_ScaleY = PropertyValuesHolder. ofFloat ("scaleY", mMenu. getScaleY (), 1f); PropertyValuesHolder menu_Alpha = PropertyValuesHolder. ofFloat ("Alpha", mMenu. getAlpha (), 1f); mMenu_animator = ObjectAnimator. ofPropertyValuesHolder (mMenu, menu_transani, menu_ScaleY, menu_Alpha); animated () ;}else {// animation to the left: PropertyValuesHolder content_transanx = PropertyValuesHolder. ofFloat ("translationX", mContent. getTranslationX (), 0); PropertyValuesHolder content_ScaleY = PropertyValuesHolder. ofFloat ("scaleY", mContent. getScaleY (), 1.0f); mContent_animator = ObjectAnimator. ofPropertyValuesHolder (mContent, content_transanx, content_ScaleY); mContent_animator.start (); PropertyValuesHolder menu_transani = PropertyValuesHolder. ofFloat ("translationX", mMenu. getTranslationX (),-DEFAULT_RIGHT_MARGIN * 3); PropertyValuesHolder menu_ScaleY = PropertyValuesHolder. ofFloat ("scaleY", mMenu. getScaleY (), 0.75f); PropertyValuesHolder menu_Alpha = PropertyValuesHolder. ofFloat ("Alpha", mMenu. getAlpha (), 0f); mMenu_animator = ObjectAnimator. ofPropertyValuesHolder (mMenu, menu_transani, menu_ScaleY, menu_Alpha); mMenu_animator.start ();}}}


Note that the event shielding and drag processing are followed by several zooming points. Then we can verify that the control is available, on the left side of the menu is a content on the right side. It should be used as needed.

public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);DragPager dragPager = new DragPager(this);View content = new View(this);content.setBackgroundColor(Color.BLUE);dragPager.setContent(content);View mentu = new View(this);mentu.setBackgroundColor(Color.RED);dragPager.setBackgroundColor(Color.argb(122, 122, 122, 122));dragPager.setMenu(mentu);setContentView(dragPager);}


 

Finally, let's see how it works.

The main reason for the card is that My GIF is not doing well. If this interface comes out, other things will be better, I wanted to thoroughly move the QQ mobile phone interface, but the unhandled Q encryption is now getting better and better, and I can't get the resources, but this interface is all out, I believe that other interfaces are easy to handle. This is the most important thing I feel in it. If you are interested, you can continue to write it down or use it as a control.


 

 


How to identify high imitation mobile phones

If not, most windows smart machines use MTK processors.
Enter * #0000 # in the standby interface and the system will automatically adjust all MTK usage in English!
Only MTK can use this command.

How can I take a photo of an Apple phone with a high imitation?

Is it an iPhone-like screen? Use a digital camera or another mobile phone.
 

Related Article

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.