360 Mobile Phone guard Suspension window effect in Android

Source: Internet
Author: User

Hello everyone, today brings us a copy of the 360 Mobile phone guard Suspension window effect of the tutorial, before beginning please allow me to say a few irrelevant nonsense.

Unconsciously, I found myself in touch with Android for nearly three years, the period of all kinds of growth without the help of the master, there are always many experts like to write their own experience on the Internet for everyone to learn, I also benefited from a lot of this, I am deeply grateful. But I found that I have never put some of my usual experience to share with you, to learn together, too no dedication to the spirit. So I had a bitter experience and decided to start blogging today, hoping to guide the developers behind me and get into the Android Developer's list faster.

OK, so much for the nonsense, let's get into today's theme.

360 Mobile Guardian I believe we all know that a lot of people on the phone will install this software, then we have a desktop suspension of its effect must not be unfamiliar. Take a look at the picture below:

The first is a small suspension window shows the current use of the amount of memory, click on a small suspension window, will pop up a large suspension window, can be a key acceleration. OK, let's simulate a similar effect now.

Let's talk about the basic implementation principle, this kind of desktop suspension window effect is similar with widget, but it is more flexible than the widget. This class is mainly implemented by WindowManager, the AddView method of calling this class is used to add a suspension window, the Updateviewlayout method is used to update the parameters of the suspension window, Removeview to remove the suspension window. There is a need to specify the parameters of the suspension window.

Windowmanager.layoutparams This class is used to provide the parameters required for a suspended window, with several variables that are often used:

Type values are used to determine the types of suspension windows, typically set to 2002, above all applications, but under the status bar.

The flags value is used to determine the behavior of the suspension window, such as not focusing, modeless dialog boxes, and so on, so that you can view the document.

The gravity value is used to determine the alignment of the suspension window, generally set to the upper-left corner alignment, so that when the suspension window is dragged to facilitate the calculation of coordinates.

x value is used to determine the position of the suspension window, if you want to move the suspension window horizontally, you need to change this value.

The Y value is used to determine the position of the suspension window, and if you want to move the suspension window vertically, you need to change this value.

The width value is used to specify how wide the suspension window is.

The height value is used to specify the elevation of the suspension window.

Create a floating window the form needs to request permission from the user, so you also need to add <uses-permission android:name= to the Androidmanifest.xml android.permission.SYSTEM_ Alert_window "/>

Related Article

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.