Advanced tutorial for Android Masters (26) — function realization of Android super imitation path menu!

Hi ~ Hello, everyone. It's been nearly three months since I started my business. Everything is pretty good. Some time ago, I used my spare time to build a Q & a website yqma. I want to be China's stackoverflow, ha ha, just under YY, I hope you can give me more support!

Well, what I'm sharing with you today is the simple implementation of the path menu, which can support custom directions (top left, top right, bottom right, bottom left), and can customize the number of menus. The difficulty is the placement of menus (dynamic setting margin), as well as the implementation of animation. In fact, the animation simply uses a translateanimation, which feels cool when n menus move together~

Custom tags are also used here. For children's shoes that you don't understand here, you can see my advanced tutorial for Android experts (IV) -- the use of custom attributes (attr.xml, typedarray) in Android! This article. Well, there's no more nonsense,

First, create an Android project named pathtest. The directory structure is as follows:

Step 2: create a new attrs.xml file under the values folder. The code is as follows:

Step 3: create a pathmenuview.java, which is our custom path menu control. The code is as follows:

Step 4: pathtestactivity.java and the layout file main.xml used are as follows:

The code of pathtestactivity.java (basically no code modification) is as follows:

The main.xml code is as follows:

The click effect of running is as follows:

Next, we modify the tutor attribute of main.xml to left_ Bottom, and modify menuresids. In pathmenuview. Java

The effects are as follows:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>