Implementation of Android Application Theme
I,Principle
1,ThemeFormat
1-1 Built-in theme: A group of pictures with a specific prefix and suffix)
1-2 external theme (only apk containing standardized named images)
2,Implementation
Obtain the specified image resource based on the specific theme and set it to view.
Steps:
2-1Obtain the Context of the specified package name
2-2Use ContextObtains the specified theme.Image Resources
The Code is as follows:
public Context getThemeContext() { if (mType == ThemeManager.THEME_TYPE_NATIVE) return mDefContext ; if (mContext != null) return mContext ; if (TextUtils.isEmpty( mPkg) || mDefContext.getPackageName().equals(mPkg )) mContext = mDefContext; try { mContext = mDefContext.createPackageContext(mPkg , Context. CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY ); } catch (NameNotFoundException e) { e.printStackTrace(); } return mContext ; }
2-3Other events
Theme installation and uninstallation affect the theme list.
Theme switching requires update ()
II,Focus
1,Nature
After the Theme architecture is complete, the rest of the work is the management of image resources.
1-1Standardized naming
Locate the specific icon on the page by name. This is the target. Therefore, the name length is required. Designers and engineers will save a lot of communication costs.
See previous blog: http://mikewang.blog.51cto.com/3826268/1020693
1-2Process
After completing several theme tasks, designers and engineers will have a basic sense of repetitive work. Relevant personnel participate in the discussion and optimize the process.
Designer:
The classification of the design scheme. The basic types include three types.
Use the ps template to save time experience for naming)
Engineer:
The corresponding template is also available. For example, if there are two ways to implement menu, prepare
Sensitive to the UI to quickly discover ui errors, which takes time to train. For more information, see the blog:
Http://mikewang.blog.51cto.com/3826268/1003333
Others:Question about fish and bear's paw: reusing image resources/Additional Screening workload
Reuse involves two aspects:
1. Reuse main program resources, such as background
Ii. Reuse of theme internal resources, such as the back key
Once reuse is involved, the total number of theme images in each set is not fixed and needs to be filtered,
Very troublesome, with a lot of work. I am now inclined to give designers a full version of the graph. This engineer
You only need to adjust the graph. If you follow this process to design a theme
The release can be completed in half a day.
2,Architecture compatibility
2-1Design-oriented, test to ensure compatibility
Theme is designed by follow designers, so the Code must be flexible or compatible.
To ensure that different designs can be implemented in one architecture. Therefore, at least three types of designs should be tested to ensure compatibility.
Once released, the main program will have a one-to-one relationship with this theme.
Modifications to Theme compatibility may cause incompatibility of other theme.
2-2Main program upgrade and theme.
When the main program continues to add new features, corresponding to add new UI elements. Only theme needs to be added.
Images. The Upgrade notification is ensured by setting the upgrade protocol.
This article mainly talks about Theme from the technical point and the Project Manager, hoping to help.
The attachment provides theme workflow. You need to modify the file name and delete the rar.
This article is from the "small new column" blog, please be sure to keep this source http://mikewang.blog.51cto.com/3826268/1208035