Android custom popupwindow imitates the pop-up menu effect in the upper right corner of wechat

The operation menu in the upper right corner of wechat looks very easy to use, so I followed it, but it's from the old version of wechat. I happen to have some resource icons of the old version of wechat in my hand. Let's share them with you.

I don't know how wechat is implemented. I use popupwindow to implement it. It is mainly divided into several parts:

1. Window layout file: popwin_ share.xml

Linear layout is adopted because there are vertical menus line by line, which is easier to control. There are two vertically arranged linear layouts in the large layout. Each linear layout has a horizontally arranged ImageView and textview, which is a very simple layout. The background of the large layout uses a picture. Of course, you can customize some other colors.

2. Popupwindow code. Here I customize a popupwindows class, which inherits from popupwindow:

It provides a construction method, including four parameters. The first parameter is the activity of the context, and the second is the click event of the menu, which is passed in from the outside and bound to the menu of each line. Of course, the specific event implementation should be written in the activity, and the latter two are the width and height of the pop-up window respectively. It also contains an animation style, which appears when the window is opened and closed.

3. Animation styles, display animation, scale Animation: push_ in.xml

Turning off animation is also scaling Animation: push_ out.xml

Style definition:

So far, our custom window has been defined. Next, let's look at using.

The click event of each submenu defines the internal class, in which you can write the click event of each submenu,

Effect preview:

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
分享
二维码
< <上一篇
下一篇>>