Interface mode switching method and device, equipment and storage medium
By receiving notifications of interface mode change and modifying view object properties, users' unsensitized theme mode switching on Android platform is achieved, solving the problems of strong invasiveness and stiff switching effects in the existing technology, and improving the user experience.
Patent Information
- Application Number
- CN202510035139.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-09
- Publication Date
- 2025-05-30
AI Technical Summary
The existing Android platform's deep and shallow theme adaptation solutions are highly invasive, with insufficient security and reliability, and the day/night mode switching effect is stiff, making it impossible to achieve user-unaware theme mode switching.
By receiving notifications of interface mode change, determine the target mode, and modify the attributes of the target view object in the current interface to the attributes corresponding to the target mode, realizing unaware switching of the interface mode.
It avoids interface reconstruction, improves switching effect, realizes user-free theme mode switching, and improves user experience.
Smart Images

Figure CN120066642A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of interface mode switching, and in particular, to an interface mode switching method, device, equipment, and storage medium. Background Art
[0002] When new energy vehicle infotainment systems are in use during travel, they often encounter tunnels, plateaus, and various weather conditions. The light intensity in these environments varies, making it very necessary for the in-vehicle system and application interfaces to automatically adapt to light and dark themes. However, the common light and dark theme adaptation solutions on the current Android (mobile operating system) platform mainly rely on third-party libraries to complete skin replacement (dark skin and light skin), and use the DayNight theme (day and night theme) to support the switching between day / night modes. Among them, the skin replacement solution has strong invasiveness because all system views need to be replaced with custom views, and its security and reliability cannot be guaranteed. The DayNight theme solution is an official product with high reliability, simple configuration, and worry-free use. However, the current interface (Activity) needs to be rebuilt to take effect, and the switching effect is very rigid.
[0003] Therefore, how to implement a theme mode switching solution that is imperceptible to users is a problem that needs to be solved by those skilled in the art. Summary of the Invention
[0004] This application provides an interface mode switching method, device, equipment, and storage medium to achieve a theme mode switching that is imperceptible to users.
[0005] In a first aspect, this application provides an interface mode switching method, including:
[0006] Receiving an interface mode change notification; wherein, the interface mode change notification is a notification generated by triggering through an interface mode change method;
[0007] Determining a target mode according to the interface mode change notification; the interface mode change notification is used to switch the interface mode to the target mode;
[0008] Determining a target view object in the current interface;
[0009] Modifying the current attribute of the target view object to a target attribute; the target attribute is an attribute corresponding to the target mode.
[0010] Optionally, before receiving the interface mode change notification, it further includes:
[0011] Creating each view object through a custom target view creation factory; wherein, the target view creation factory creates each view object by using system methods;
[0012] Create a theme manager through the target view creation factory;
[0013] Store each view object in the theme manager;
[0014] Store the attributes of each view object in different interface modes in the theme manager.
[0015] Optionally, before receiving the interface mode change notification, it further includes:
[0016] Set resource folders corresponding to different interface modes; the resource folders include resources corresponding to different attributes.
[0017] Optionally, the setting of resource folders corresponding to different interface modes includes:
[0018] Set a dark theme resource folder corresponding to the dark theme interface mode; the dark theme resource folder includes: resources corresponding to the attributes of each view object;
[0019] Set a light theme resource folder corresponding to the light theme interface mode; the light theme resource folder includes: resources corresponding to the attributes of each view object.
[0020] Optionally, before receiving the interface mode change notification, it further includes:
[0021] Set the mode change processing method of the interface to the interface mode change method, and the interface mode change method is the onConfigurationChanged method.
[0022] Optionally, the modification of the current attribute of the target view object to the target attribute includes:
[0023] Determine the attribute setting method corresponding to the target view object;
[0024] Call the attribute setting method to modify the current attribute of the target view object to the target attribute.
[0025] Optionally, calling the attribute setting method to modify the current attribute of the target view object to the target attribute includes:
[0026] Determine the target attribute of the target view object in the target mode;
[0027] Load the resources corresponding to each target attribute through the attribute setting method.
[0028] In a second aspect, the present application provides an interface mode switching device, including:
[0029] A receiving module, configured to receive an interface mode change notification; wherein, the interface mode change notification is a notification generated by triggering an interface mode change method.
[0030] A first determination module, configured to determine a target mode according to the interface mode change notification; the interface mode change notification is used to switch the interface mode to the target mode.
[0031] A second determination module, configured to determine a target view object in the current interface.
[0032] A modification module, configured to modify the current attributes of the target view object to target attributes; the target attributes are attributes corresponding to the target mode.
[0033] In a third aspect, the present application provides an electronic device, including:
[0034] A processor, a memory, and a computer program stored on the memory and executable on the processor, and the processor executes the above interface mode switching method of the present application through the computer program.
[0035] In a fourth aspect, the present application further provides a computer storage medium, where the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the above interface mode switching method of the present application.
[0036] The above technical solutions provided by the embodiments of the present application have the following advantages compared with the prior art: The present application provides an interface mode switching solution. After receiving an interface mode change notification generated by triggering an interface mode change method, this solution determines the target mode to be switched according to the interface mode change notification, and determines the target view object in the current interface; modifies the current attributes of the target view object to attributes corresponding to the target mode. It can be seen that in the present application, after the interface mode changes, a corresponding notification can be generated by triggering an interface mode change method, avoiding interface reconstruction; and after the interface mode changes in the present application, there is no need to reconstruct the view object, and only the attributes of the view object need to be modified to the attributes corresponding to the switched target mode, so as to achieve a seamless switch of the interface mode and improve the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The drawings here are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present invention and used together with the specification to explain the principles of the present invention.
[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0039] One or more embodiments are exemplarily illustrated by the pictures in the corresponding accompanying drawings. These exemplary illustrations do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, unless otherwise stated, the drawings in the figures do not constitute a proportional limitation.
[0040] Figure 1 Schematic diagram of the process of a method for switching interface modes provided by an embodiment of the present application;
[0041] Figure 2 Schematic diagram of the process of an adaptation operation execution provided by an embodiment of the present application;
[0042] Figure 3 Schematic diagram of the display effect of a text view provided by an embodiment of the present application on an application;
[0043] Figure 4 Schematic diagram of the process of another method for switching interface modes provided by an embodiment of the present application;
[0044] Figure 5 Schematic diagram of the structure of a device for switching interface modes provided by an embodiment of the present application;
[0045] Figure 6 Schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0046] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts belong to the scope of protection of the present application.
[0047] The following disclosure provides many different embodiments or examples for implementing different structures of the present invention. To simplify the disclosure of the present invention, the components and settings of specific examples are described below. Of course, they are only examples and are not intended to limit the present invention. In addition, the present invention may repeat reference numerals and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0048] The present application provides an interface mode switching method, apparatus, device, and storage medium to achieve a theme mode switch without user awareness.
[0049] See Figure 1 , which is a schematic flowchart of an interface mode switching method provided by an embodiment of the present application. The method specifically includes the following steps:
[0050] S101. Receive an interface mode change notification; the interface mode change notification is a notification generated by triggering through an interface mode change method;
[0051] In the present application, the interface mode is an interface mode corresponding to different system themes. If the system themes include a dark theme and a light theme, then the interface mode includes: a dark theme interface mode and a light theme interface mode. The interface mode can be set according to actual needs. For example, if the present application further includes other types of system themes, then the interface mode in the present application further includes an interface mode corresponding to other types of system themes. In the present application, only the example where the interface mode includes a dark theme interface mode and a light theme interface mode is used for illustration.
[0052] Among them, the dark theme is applied to the Android system interface and applications running on the device, which can significantly reduce power consumption, improve visibility for users with low vision and those sensitive to strong light, and allow users to use the device more easily in a dimly lit environment. The light theme is applied to the Android system interface and applications running on the device, which can improve readability and legibility. Especially in an environment with sufficient light, it can reduce eye fatigue, enhance the user experience, and also improve the clarity and responsiveness of the application. On a light background, the contrast between text and icons is higher, making interface elements more prominent. Users can more easily identify and distinguish different information and interaction elements, thereby improving the overall user experience. The light theme also helps to enhance the usability and accessibility of the application. For some users with poor eyesight, the high-contrast design provided by the light theme makes the content more clearly visible, thereby improving the usability and inclusiveness of the application.
[0053] In the present application, after the system theme changes, the interface mode change method will be called, and an interface mode change notification will be generated by triggering through the interface mode change method. After receiving this interface mode change notification, the present application can switch the interface theme through subsequent steps. The interface mode change method is specifically the onConfigurationChanged method. Calling this method after the system theme changes can avoid Activity reconstruction and improve the switching effect.
[0054] S102. Determine the target mode according to the interface mode change notification, which is used to switch the interface mode to the target mode.
[0055] In this application, the target mode is the mode after the interface mode is switched. For example, the interface mode includes a dark theme interface mode and a light theme interface mode. If the current interface mode is the dark theme interface mode, the interface mode change notification is used to switch the interface mode to the light theme interface mode, and this light theme interface mode is the target mode.
[0056] S103. Determine the target view object in the current interface.
[0057] In this embodiment, when adjusting the interface mode, it is first necessary to determine the view objects in the current interface, and change the mode of the interface by changing the attributes of the view objects in the current interface. In this application, for distinction, the view object whose attributes need to be modified when switching the interface mode is called the target view object.
[0058] S104. Modify the current attribute of the target view object to the target attribute, where the target attribute is the attribute corresponding to the target mode.
[0059] The attribute in this application is information describing the characteristics of the view object, and this attribute includes: the font color attribute (textColor) and background attribute (background) of TextView (the component that displays the string), etc.; in different interface modes, the attributes of the same view object are different. For example, if the current interface mode is the dark theme interface mode, the font color attribute of TextView is white, and if the current interface mode is the light theme interface mode, the font color attribute of TextView is black. Therefore, in this application, it is necessary to modify the current attribute of the target view object to the target attribute, and this target attribute is the modified attribute.
[0060] For example, when the current interface mode is the dark theme interface mode, if an interface mode change notification is received, and the target mode to be switched at this time is the light theme interface mode. In the current interface, the target view object whose attributes need to be modified is the text view object. The font color attribute of this text view object is white in the dark theme interface mode, and the font color attribute of this text view object is black in the light theme interface mode. Therefore, this target attribute is black, that is, it is necessary to modify the font color attribute of the text view object from the current white to black; similarly, for other target view objects in the current interface whose attributes need to be modified, their attributes are also modified to the target attribute in this way, so as to achieve the switching of different interface modes.
[0061] In summary, in this application, after the interface mode changes, corresponding notifications are triggered and generated through the interface mode change method, which can avoid interface reconstruction. Moreover, in this application, after the interface mode changes, there is no need to reconstruct the view object. Instead, only the attributes of the view object need to be modified to the attributes corresponding to the target mode after switching. The entire interface mode switching process does not require reconstructing the interface and views, realizing a seamless switching solution for the mode and improving the user experience.
[0062] Based on the above embodiments, in order to achieve seamless switching of the interface mode, this application needs to perform some preparatory operations in advance. Refer to Figure 2 , which is a schematic diagram of an adaptation operation execution process provided by an embodiment of the present invention. The process specifically includes the following steps:
[0063] S201. Set resource folders corresponding to different interface modes; the resource folders include resources corresponding to different attributes;
[0064] In this application, first, different resource folders need to be set according to different interface modes. Different interface modes have different resource folders, and these resource folders include values (character resources), drawable (image resources), and so on.
[0065] In some embodiments of this application, if the interface modes include a dark theme interface mode and a light theme interface mode, the process of setting resource folders corresponding to different interface modes specifically includes: setting a dark theme resource folder corresponding to the dark theme interface mode; the dark theme resource folder includes: resources corresponding to the attributes of each view object; setting a light theme resource folder corresponding to the light theme interface mode; the light theme resource folder includes: resources corresponding to the attributes of each view object. Among them, if the system theme includes a dark theme and a light theme, and there is already a resource folder for the light theme in the system, only the resource folder used for the dark theme needs to be added at this time. For example: add dark resource folders such as values-night (dark theme character resources), drawable-night (dark theme image resources), etc., and ensure that the resource names under the folders are the same, so as to achieve mode switching by loading resources under different resource folders.
[0066] S202. Set the mode change processing method of the interface to the interface mode change method, and this interface mode change method is the onConfigurationChanged method;
[0067] In this application, it is necessary to declare in advance in the AndroidManifest.xml file (information description file) the mode change handling method for each Activity to handle uiMode (interface mode) configuration changes. In this application, the mode change handling method is set to
[0068] the onConfigurationChanged method. After the above settings, when the theme of the application changes through system settings, the onConfigurationChanged() method will be called. The Chinese meaning of the onConfigurationChanged() method is the interface mode change method. After the onConfigurationChanged() method is called for the interface mode, it will send an interface mode change notification. According to this interface mode change notification, this application can modify the interface mode by modifying the properties of the view object; moreover, when this application calls
[0069] the onConfigurationChanged() method, the Activity will not be rebuilt, realizing a mode switching process that is imperceptible to the user.
[0070] The following is the specific declaration content of the AndroidManifest.xml file:
[0071]
[0072] S203. Create each view object through a custom target view creation factory; among them, the target view creation factory creates each view object using system methods;
[0073] S204. Create a theme manager through the target view creation factory;
[0074] S205. Store each view object in the theme manager;
[0075] S206. Store the properties of each view object in different interface modes in the theme manager.
[0076] In this application, it is also necessary to customize the target view creation factory and replace the original view creation factory through this target view creation factory. The original view creation factory is: LayoutInflater.Factory, and the target view creation factory is:
[0077] DayNightLayoutInflaterFactory, and make the target view creation factory inherit from the LayoutInflaterFactory class. In the Activity, use the setFactory2 method of LayoutInflater (layout inflater) (the method for setting a custom factory) to set the view creation factory to the target view creation factory in the present invention. The target view creation factory intercepts the LayoutInflater from scanning and parsing the xml (Extensible Markup Language) file under layout (layout), and this xml file is used to define the structure of an interface. For example, the following content is defined in the xml file:
[0078]
[0079] As can be seen from the above content, there is only one text view "Hello Word" in the defined interface, the text color textColor is black, and the background color background is white. See Figure 3 , which is the schematic diagram of the display effect of the text view provided in the embodiment of the present invention in the application.
[0080] In this application, the target view creation factory DayNightLayoutInflaterFactory is responsible for creating the view object. Although the view object is created in the target view creation factory, the target view creation factory uses the system method to create the view. In this way, the application can use the system-native view instead of the custom view, thus ensuring that the application is not invaded. The target view creation factory is also responsible for identifying and obtaining the view object, as well as the attributes of the view object that need to adapt to the light and dark themes, such as the text color attribute textColor and the background attribute background of TextView. Finally, the target view creation factory will create a corresponding theme manager DayNightViewMannager, and store the created view object and the attributes of the view object that need to adapt to the light and dark theme resources in the theme manager. After the above settings, when switching themes, the view object in the theme manager can be directly used for adaptation to different themes, without the need to re-scan the interface view object, saving extra work and improving the adaptation efficiency.
[0081] In this application, by setting a resource folder, setting a mode change processing method, and creating view objects and attributes, a basis for the switching of the interface mode is provided. This application does not specifically limit the execution order among the above steps. The mode change processing method can be set first, then the resource folder can be set, and finally the view objects and attributes can be created. It can also be in other execution orders. This application only uses the order of S201 - S207 as an example to illustrate the entire process. The interface components involved in Android development include Activity (display interface), Fragment (fragment), Dialog (dialog box), and PopWindow (pop - up window). After setting through the above process, this application can provide corresponding base classes for the above interface components: DayNightActivity (light - dark mode display interface), DayNightFragment (light - dark mode fragment), DayNightDialog (light - dark mode dialog box), and DayNightPopWindow (light - dark mode pop - up window). Developers only need to inherit these base classes without additional adaptation work, which greatly improves the developer efficiency. This method makes the integration of this solution simple, thus enhancing the developer efficiency.
[0082] In summary, before implementing mode switching in this application, it is necessary to set resources corresponding to different interface modes. In this way, when switching modes, the mode can be switched by loading resources corresponding to different interface modes. If the interface mode includes a dark - theme interface mode and a light - theme interface mode, correspondingly, the resource folder includes a dark - theme resource folder and a light - theme folder. When switching between the light and dark themes, the automatic switching of the light - dark mode can be achieved by simply loading the corresponding resources. This application also sets the mode change processing method as the interface mode change method onConfigurationChanged method. Invoking this method in this application will not cause the interface to be rebuilt, realizing a mode switch without the user's awareness.
[0083] Moreover, before implementing mode switching in this application, it is necessary to create a factory for the target view after replacement, recreate each view object using the system method, and determine the attributes of each view object in different interface modes. Through this setting method, the attributes of each view object can be changed when switching the interface mode. And when switching the interface mode in this application, the native Android system view View is used. Although a custom view View creation factory DayNightLayoutInflaterFactory is defined, but
[0084] The method of creating a view internally by the DayNightLayoutInflaterFactory is still the method used by the Android system to create a view. Therefore, using this solution is very safe and reliable.
[0085] See Figure 4 , which is a schematic flowchart of another interface mode switching method provided by an embodiment of this application. The method specifically includes the following steps:
[0086] S301. Receive an interface mode change notification; this interface mode change notification is a notification generated by triggering through an interface mode change method;
[0087] S302. Determine the target mode according to the interface mode change notification; this interface mode change notification is used to switch the interface mode to the target mode;
[0088] S303. Determine the target view object in the current interface;
[0089] S304. Determine the attribute setting method corresponding to the target view object;
[0090] S305. Call the attribute setting method to modify the current attributes of the target view object to the target attributes; these target attributes are the attributes corresponding to the target mode.
[0091] In this application, when the interface mode changes, it is necessary to reset the attributes of the view, and these attributes are modified by automatically loading the resources in the resource folder corresponding to the mode. In this application, the theme manager created by the target view creation factory can be used to implement the switching of the interface mode, that is: the theme manager receives the interface mode change notification, determines the target mode according to the interface mode change notification, then determines the target view object in the current interface, determines the attribute setting method corresponding to the target view object, calls the attribute setting method, and modifies the current attributes of the target view object to the target attributes. Moreover, in some embodiments of this application, the process of calling the attribute setting method to modify the current attributes of the target view object to the target attributes includes: determining the target attributes of the target view object in the target mode; loading the resources corresponding to each target attribute through the attribute setting method.
[0092] Among them, the theme manager is responsible for managing the interface View and adapting to light and dark themes. When the manager is created, it will automatically register the method onConfigurationChanged for listening to interface mode changes. When the interface mode changes, the theme manager will receive a notification of the interface mode change. The theme manager will call the property setting methods of all view objects in the interface that need to adapt to light and dark theme attributes one by one to modify the attributes of each view resource. The property setting methods include: the setTextColor() method for setting the font color attribute of TextView, the setBackground() method for setting the background attribute, etc. There is no specific limitation here, as long as it is a method for modifying attributes. When the theme manager calls these property setting methods, due to the characteristics of the Android system, it will automatically select the resources in the corresponding resource folder according to the value of the target mode. For the light mode, it uses the resources under values, drawable, etc., and for the dark mode, it uses the resources under values-night, drawable-night, etc.
[0093] In summary, when modifying the attributes of the view object in this application, the attributes of each view are specifically changed by calling the property setting method, so as to realize the automatic switching of the interface mode. Among them, the property setting method realizes the modification of the attribute by loading the resource corresponding to the target attribute, and then realizes the seamless switching of the interface mode. Moreover, in the whole process of switching the theme interface mode in this application, the interface Activity is not created, and the view View only has its properties reset without being created either, which can achieve seamless switching between different themes, with high performance efficiency and no perception by the user, thus improving the user experience.
[0094] See Figure 5 , Figure 5 which is a schematic structural diagram of an interface mode switching device provided by an embodiment of this application. The device specifically includes:
[0095] A receiving module 11, configured to receive a notification of an interface mode change; among them, the interface mode change notification is a notification triggered and generated by an interface mode change method;
[0096] A first determination module 12, configured to determine a target mode according to the interface mode change notification; the interface mode change notification is used to switch the interface mode to the target mode;
[0097] A second determination module 13, configured to determine a target view object in the current interface;
[0098] A modification module 14, configured to modify the current attribute of the target view object to a target attribute; the target attribute is an attribute corresponding to the target mode.
[0099] As an alternative embodiment, the interface mode switching device further includes:
[0100] A first creation module, configured to create each view object through a custom target view creation factory; wherein, the target view creation factory creates each view object by using system methods;
[0101] A second creation module, configured to create a theme manager through the target view creation factory;
[0102] A first storage module, configured to store each view object into the theme manager;
[0103] A second storage module, configured to store the attributes of each view object in different interface modes into the theme manager.
[0104] As an alternative embodiment, the interface mode switching device further includes:
[0105] A first setting module, configured to set resource folders corresponding to different interface modes; the resource folders include resources corresponding to different attributes.
[0106] As an alternative embodiment, the first setting module includes:
[0107] A first setting unit, configured to set a dark theme resource folder corresponding to the dark theme interface mode; the dark theme resource folder includes: resources corresponding to the attributes of each view object;
[0108] A second setting unit, configured to set a light theme resource folder corresponding to the light theme interface mode; the light theme resource folder includes: resources corresponding to the attributes of each view object.
[0109] As an alternative embodiment, the interface mode switching device further includes:
[0110] A second setting module, configured to set the mode change processing method of the interface to the interface mode change method, and the interface mode change method is the onConfigurationChanged method.
[0111] As an alternative embodiment, the modification module includes:
[0112] A determination unit, configured to determine an attribute setting method corresponding to the target view object;
[0113] A modification unit, configured to call the attribute setting method to modify the current attribute of the target view object to a target attribute.
[0114] As an alternative embodiment, the determination unit includes:
[0115] A determination subunit, configured to determine target attributes of a target view object in a target mode;
[0116] A loading subunit, configured to load resources corresponding to respective target attributes by using the attribute setting method.
[0117] Regarding the device in the above embodiments, the specific manners in which each module performs operations have been described in detail in the embodiments related to the method, and will not be elaborated herein.
[0118] See Figure 6 , Figure 6 which is a schematic structural diagram of an electronic device provided by an embodiment of the present application. The electronic device specifically includes:
[0119] A processor 21, a memory 22, and a computer program stored on the memory 22 and executable on the processor 21. The processor 21 executes the interface mode switching method described in any of the above method embodiments through the computer program.
[0120] Wherein, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 may be implemented in at least one of the following hardware forms: DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in a wake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may further include an AI (Artificial Intelligence) processor, and the AI processor is used to process computational operations related to machine learning.
[0121] The memory 22 may include one or more computer-readable storage media, which may be non-transitory. The memory 22 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices and flash storage devices. In this embodiment, the memory 22 is at least used to store the following computer program 221. After the computer program is loaded and executed by the processor 21, it can implement the relevant steps in the interface mode switching method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 22 may also include an operating system 222, data 223, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 222 may include Windows, Unix, Linux, etc.
[0122] In some embodiments, the electronic device may further include a display screen 23, an input / output interface 24, a communication interface 25, sensors 26, a power supply 27, and a communication bus 28.
[0123] Of course, Figure 6 The structure of the illustrated electronic device does not constitute a limitation on the electronic device in the embodiments of the present application. In practical applications, the electronic device may include more or fewer components than Figure 6 those shown, or combine certain components.
[0124] In another exemplary embodiment, a computer storage medium is also provided. When the program instructions are executed by the processor, the interface mode switching method described in any of the foregoing method embodiments is implemented. Among them, the storage medium may include: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs.
[0125] Optionally, the specific examples in this embodiment may refer to the examples described in the foregoing embodiments, and will not be elaborated herein.
[0126] It should be understood that the terms used herein are for the purpose of describing particular example embodiments only and are not intended to be limiting. Unless the context clearly dictates otherwise, the singular forms "a", "an", and "the" as used herein may also include the plural forms. The terms "comprising", "including", "containing", and "having" are inclusive and thus specify the presence of stated features, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not to be construed as necessarily requiring their performance in the particular order described or illustrated, unless an order of performance is explicitly stated. It should also be understood that additional or alternative steps may be used.
[0127] The foregoing are only specific embodiments of the present invention, enabling those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for switching interface modes, characterized in that: include: Receiving an interface mode change notification; wherein the interface mode change notification is a notification triggered by an interface mode change method; Determine the target mode according to the interface mode change notification; the interface mode change notification is used to switch the interface mode to the target mode; Determine the target view object in the current interface; The current attribute of the target view object is modified to a target attribute; the target attribute is an attribute corresponding to the target mode.
2. The interface mode switching method according to claim 1, characterized in that: Before receiving the interface mode change notification, the method further includes: Creating each view object through a customized target view creation factory; wherein the target view creation factory uses a system method to create each view object; Create a theme manager by creating a factory through the target view; Storing each view object in the theme manager; The properties of each view object in different interface modes are stored in the theme manager.
3. The interface mode switching method according to claim 1, characterized in that: Before receiving the interface mode change notification, the method further includes: Resource folders corresponding to different interface modes are set; the resource folders include resources corresponding to different attributes.
4. The interface mode switching method according to claim 1, characterized in that: The resource folders corresponding to different interface modes are set up, including: Setting a dark theme resource folder corresponding to the dark theme interface mode; the dark theme resource folder includes: resources of attributes corresponding to each view object; A light theme resource folder corresponding to the light theme interface mode is set; the light theme resource folder includes: resources of attributes corresponding to each view object.
5. The interface mode switching method according to claim 1, characterized in that: Before receiving the interface mode change notification, the method further includes: The mode change processing method of the setting interface is the interface mode change method, and the interface mode change method is the onConfigurationChanged method.
6. The interface mode switching method according to any one of claims 1 to 5, characterized in that: The step of modifying the current property of the target view object to the target property includes: Determine a property setting method corresponding to the target view object; The property setting method is called to modify the current property of the target view object to the target property.
7. The interface mode switching method according to claim 6, characterized in that: Calling the property setting method to modify the current property of the target view object to the target property includes: Determine the target attributes of the target view object in target mode; The resource corresponding to each target attribute is loaded through the attribute setting method.
8. An interface mode switching device, characterized in that: include: A receiving module, used to receive an interface mode change notification; wherein the interface mode change notification is a notification triggered by an interface mode change method; A first determination module, configured to determine a target mode according to the interface mode change notification; the interface mode change notification is used to switch the interface mode to the target mode; The second determination module is used to determine the target view object in the current interface; The modification module is used to modify the current attribute of the target view object to a target attribute; the target attribute is an attribute corresponding to the target mode.
9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the interface mode switching method described in any one of claims 1 to 7 of the present application through the computer program.
10. A computer storage medium, characterized in that: The computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the interface mode switching method described in any one of claims 1 to 7 of the present application.