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