9. Create a rounded corner Image
The main principle is to use a mask to create a rounded corner box and place the image below:
1. Bitmap myCoolBitmap = ...;
2. int w = myCoolBitmap. getWidth (), h = myCoolBitmap. getHeight ();
3. Bitmap rounder = Bitmap. createBitmap (w, h, Bitmap. Config. ARGB_8888 );
4. Canvas canvas = new Canvas (rounder );
5. Paint xferPaint = new Paint (Paint. ANTI_ALIAS_FLAG );
6. xferPaint. setColor (Color. RED );
7. canvas. drawRoundRect (new RectF (, w, h), 20366f, 20366f, xferPaint );
8. xferPaint. setXfermode (new porterduxfermode (PorterDuff. Mode. DST_IN ));
1. // then implement
2. canvas. drawBitmap (myCoolBitmap, 0, 0, null );
3. canvas. drawBitmap (rounder, 0, 0, xferPaint );
10. Add a number to the icon on the notification to indicate how many unread items are displayed.
1. Notification notification = new Notification (icon, tickerText, when );
2. notification. number = 4;
11 background gradient:
First, create the file drawable/shape. xml.
1. <? Xml version = "1.0" encoding = "UTF-8"?>
2. <shape xmlns: android = "http://schemas.android. com/apk/res/android" android: shape = "rectangle">
3. <gradient android: startColor = "# FFFFFFFF" android: endColor = "# FFFF0000"
3. android: angle = "270"/>
5. </shape>
Set the start color, end color, and angle of the gradient in this file)
Create a topic values/style. xml
1. <? Xml version = "1.0" encoding = "UTF-8"?>
2. <resources>
3. <style name = "NewTheme" parent = "android: Theme">
4. <item name = "android: background"> @ drawable/shape </item>
5. </style>
6. </resources>
Introduce the topic to the application or activity in the AndroidManifest. xml file, for example:
1. <activity android: name = ". ShapeDemo" android: theme = "@ style/NewTheme">
This method also applies to control http://17f8.cn/trackback.php? TbID = 259 & extra = 9d45e9
12. Store data when you save static data in an instance, if this example is disabled, the next instance will be null if you want to reference static data. Here, you must override applition.
1. public class MyApplication extends Application {
2. private String thing = null;
3. public String getThing (){
4. return thing;
5 .}
6. public void setThing (String thing ){
7. this. thing = thing ;}
8 .}
9. public class MyActivity extends Activity {
10. private MyApplication app;
11. public void onCreate (Bundle savedInstanceState ){
12. super. onCreate (savedInstanceState );
13. app = (MyApplication) getApplication ());
14. String thing = app. getThing ();
15 .}
}
From LuoXianXiong, your partner