Arcmenu How to modify the system menu similar to Xiaomi

Source: Internet
Author: User

In the source code, this paragraph is the size of the application space, for those child controls, or you appear there is no place to show. @Override  protected void onmeasure (int  WIDTHMEASURESPEC,&NBSP;INT&NBSP;HEIGHTMEASURESPEC)  {  final int radius =  Mradius = msetradius == -1 ? computeradius (    math.abs ( Mtodegrees - mfromdegrees),  getchildcount (),    mchildsize,  Mchildpadding, min_radius)  : msetradius;  final int size = radius  * 2 + mchildsize + mchildpadding    + mlayoutpadding  * 2;  setmeasureddimension (size, size);   final int count =  getchildcount ();  for  (int i = 0; i < count; i++)  {   getchildat (i)      .measure (        measurespec.makemeasurespec (Mchildsize,         measurespec.exactly),        measurespec.makemeasurespec (mchildsize,          measurespec.exactly));   } }
This code is triggered when the animation is,requestlayout , so that the child controls are displayed in the real position. Originally here  getheight ()/2, I changed to  gethe...  to place the control at the bottom To form the bottom-up effect. @Override  protected void onlayout (boolean changed, int l,  INT&NBSP;T,&NBSP;INT&NBSP;R,&NBSP;INT&NBSP;B)  {  final int centerX =  GetWidth ()  / 2;  final int centery = getheight ();   final  int radius = mExpanded ? mRadius : 0; //  returns to the center point if the radius is 0.   final int childcount = getchildcount ();  final float  perdegrees =  (mtodegrees - mfromdegrees)  /  (childcount - 1);   float degrees = mFromDegrees; //  Angle .  for  (int i =  0; i < childcount; i++)  {   Rect frame =  Computechildframe (Centerx, centery,&nbsP;radius, degrees,     mchildsize);   degrees +=  Perdegrees;   getchildat (i). Layout (frame.left, frame.top, frame.right,      frame.bottom);   } }
  @SuppressLint ("Newapi")  private void bindchildanimation (final view child,  Final int index,   final long duration)  {  /**    * true :  back . false :  out.    */  final boolean  expanded = mExpanded; //  pop up, bounce the animated spin.   final int centerx =  getwidth ()  / 2;  final int centery = getheight ();   Final int radius = expanded ? 0 : mradius;  final int  childcount = getchildcount ();  //  (360 - 180)  /  (5 -  1)  = 45  degrees  !!   If this is 5, you can still reach the center point, if 6, 7, here need to change 45.  final float perdegrees =  (mtodegrees  - mfromdegrees)  /  (childcount - 1);   rect frame;  if  (!expanded)  {   frame = computechildframe (centerX,  Centery, radius, mfromdegrees     + index * perdegrees,  mchildsize); //  calculations need to move past positions .  } else {   frame =  Computechildframe (centerx, centery, mradius, mfromdegrees     +  ( 270 - mfromdegrees),  mchildsize); //  calculation needs to move past the position .  }  //   rect framedown = computechildframe (centerx, centery, 0, mfromdegrees     +  (270 - mfromdegrees),  mchildsize); //  calculation needs to move past position .   //  final int toxdelta = frame.left - child.getleft ();  //   Ready-to-move left -                //  the original left.  of the control final int toydelta = frame.top - child.gettop (); //   Interpolator interpolator = mexpanded ? new accelerateinterpolator ()      : new overshootinterpolator (1.5f); //  accelerator .  final long  Startoffset = computestartoffset (childcount, mexpanded,    index, 0.1f ,  duration, interpolator); //    //  rotate animation.  createshrinkanimation   Shrink back the animation, conversely.   animation animation = mexpanded ? createshrinkanimation (0 ,  toxdelta, 0,    toydelta, startoffset, duration + 300,  interpolator, framedown)     : createexpandanimation (0, toXDelta,  0, toydelta, startoffset,      duration, interpolator);  //  animation effects.   if  (mexpanded)  {   this.cb.onswitchgone ();  } else {    this.cb.onswitchvisible ();  }  final boolean islast =  Gettransformedindex (Expanded, childcount, index)  == childCount - 1;   Animation.setanimationlistener (New animationlistener ()  {    @Override     public void onanimationstart (animation animation)  {   }     @Override    public void onanimationrepeat (animation animation)  {    }    @Override    public void onanimationend (Animation  animation)  {    if  (islast)  {      Postdelayed (new runnable ()  {       @Override        public void run ()  {&nbsP;      onallanimationsend ();      }      }, 0);     }   }  });   Child.setanimation (animation); //  set animation.  

And then modify the angle. When the external todegrees, the mfromdegrees is added and reduced, it starts to spin.

public void Setarc (float fromdegrees, float todegrees, Arcmenudegreescallback CB) {if (mfromdegrees = = Fromdegrees &am  p;& mtodegrees = = todegrees) {return;  } mfromdegrees = Fromdegrees;  Mtodegrees = todegrees; Requestlayout (); if (CB! = null) cb.onlastdegrees (); }

Arcmenu How to modify the system menu similar to Xiaomi

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.