Learning Satellite Menu

Source: Internet
Author: User

Learn to stick to the bottom of your own writing Center menu

Transfer from http://www.cnblogs.com/persist-confident/p/4487386.html

Read the Hyman Teacher's video, it sounds a little confused, so I want to realize the implementation of the satellite menu to summarize. Long story short, here's a summary:

One, custom ViewGroup
1), Custom properties file

The definition of the property:

<attr name= "Position" >
<enum name= "left_top" value= "0"/>
<enum name= "Left_bottom" value= "1"/>
<enum name= "Right_top" value= "2"/>
<enum name= "Right_bottom" value= "3"/>
<enum name= "Center_bottom" value= "4"/>
</attr>
<attr name= "radius" format= "Dimension"/>

It is important to note how to associate a property file with a custom ViewGroup

=====================================================

It still has problems

The main thing is that its sub-menu is not fully positioned correctly

======-------------------------The following is what he wrote (indeed a desirable place)--------------------===========

4) about the layout of custom controls

Here I focus mainly on the layout of the main menu in the middle of the following position:

First get the length width of the main menu:

int width = mcbutton.getmeasuredwidth ();
int height = mcbutton.getmeasuredheight ();

To place the main menu in the middle of the screen:

Then his x-coordinate is L = getmeasuredwidth ()/2-WIDTH/2;

The Y coordinate is: t = getmeasuredheight ()-height;

Final layout

Mcbutton.layout (L, T, L + width, t + height);

The layout location of the sub-menu

T1 = (int) (Mradius * Math.sin (Math.pi/count * (i + 1)));
l1= (int) (Mradius * Math.Cos (Math.pi/count * (i + 1)));

Coordinates of the final sub-menu

L = getmeasuredwidth ()/2-WIDTH/2-L1;
t = getmeasuredheight ()-height-t2;

Sub-menu Layout

Child.layout (L, T, L + width, t + height);

Connect it through Arcmenu, and Arcmenu is our custom ViewGroup

<declare-styleable name= "Arcmenu" >
<attr name= "position"/>
<attr name= "radius"/>
</declare-styleable>

=====================------This is his result-------===============

The end result is as follows:

=====================------This is my result-------===============

------------------------------------------------------------------------------------------------

Still need to improve, hope to know why the great God advice!

Learning Satellite Menu

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.