First show screenshots
1. QQToast display showing normal prompts
2. QQToast display showing success prompt
3. QQToast display showing failure prompt
4. QQToast display showing warning prompt
Second, the principle analysis
The first step is to create a Toast layout file
To achieve this layout is very easy, just add a LinearLayout layout and set it to horizontal arrangement, and add ImageVIew controls and TextView controls to the LinearLayout layout.
The next step is to set the background of the LinearLayout layout. We can use xml to achieve the rounded semi-transparent background in the picture.
The second step, create a Toast instance and set Gravity, Duration, View
First load the View, and set the image of the ImageView control and the text of the TextView control
Next, create a Toast and set the corresponding parameters
The third step is to encapsulate the QQToast class
First create the constructor of QQToast
Next, create the makeText method. In order to improve the scalability of the code, we create several different makeText methods.
Step 4 and you're done!
Three, code sharing
Note: Downloading requires 1 point, you can earn it back by commenting, thank you for your support!
http://download.csdn.net/detail/cc_want/9180575