Segment control configuration method and device, terminal equipment and medium
By switching the layout direction according to the number of copy lines of the subcontrol in the Segment control, the problem that the Segment control cannot adapt under different typesettings is solved, and adaptive layout is realized, improving the user experience and interface aesthetics.
Patent Information
- Application Number
- CN202410996192.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-11-12
AI Technical Summary
The Segment control cannot be adapted in different typesetting directions, resulting in incomplete copy display of sub-controls and affecting the user experience.
By determining the current layout direction of the Segment control to be configured, switch the layout direction according to the number of copy lines of the child control, switch from horizontal to vertical or vice versa, use the preset test control to obtain the number of copy lines, and update the child control's Height or width for adaptive layout.
Improve the adaptability of Segment controls in different typesetting directions, avoid the problem of incomplete copy display, and improve the user experience and interface aesthetics.
Smart Images

Figure CN118939339A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of control configuration, and in particular to a Segment control configuration method, device, terminal device and medium. Background Art
[0002] The Segment control is a segmented selection control used for interface titles. With the increase in the types of screens, this type of control has been widely used in various scenarios such as car displays. The layout direction of the Segment control is divided into horizontal layout and vertical layout. In the application interface, the layout and size of the Segment control and its sub-controls are often fixed. Therefore, in some application scenarios, the layout direction of the sub-control text will not match the layout direction. For example, the same semantics requires two characters when the sub-control text is in Chinese, but some small languages may require up to eight characters. At this time, the horizontal layout of the Segment control obviously cannot meet the needs and will affect the user experience. Summary of the invention
[0003] The present invention application provides a Segment control configuration method, apparatus, terminal device and medium to improve the adaptability of the Segment control in different layouts.
[0004] In order to solve the above technical problems, the first aspect of the present invention application provides a Segment control configuration method, including:
[0005] Determine the current layout direction of the Segment control to be configured, where the Segment control to be configured includes multiple sub-controls;
[0006] When the current layout direction is horizontal layout, the first text line number of each sub-control is obtained respectively; and when the maximum first text line number is greater than the preset horizontal maximum line number, the layout direction of the Segment control to be configured is switched to vertical layout;
[0007] When the current layout direction is a vertical layout, the maximum number of second text lines in each sub-control is obtained through a preset test control; and when the maximum number of second text lines is less than the maximum number of lines in the horizontal version, the layout direction of the Segment control to be configured is switched to a horizontal layout; the control parameters of the test control are the same as the sub-control parameters when the layout direction of the Segment control to be configured is a horizontal layout.
[0008] In this application, when the current layout direction is horizontal, when the largest number of first text lines in each sub-control is greater than the preset maximum number of horizontal lines, the layout direction of the Segment control is switched to vertical layout, which can avoid the problem of incomplete display of sub-control text; when the current layout direction is vertical, when the largest number of second text lines in each sub-control is less than the maximum number of horizontal lines, the layout direction of the Segment control to be configured is switched to horizontal, and the application interface is simpler, so that the Segment control layout can be adaptively switched according to the number of text lines in the sub-control, thereby improving the adaptability of the Segment control in different layouts and enhancing the user experience.
[0009] In some implementations of the first aspect, obtaining the maximum number of second text lines in each sub-control by using a preset test control includes:
[0010] The preset array is traversed and accessed, and the text width of each sub-control is obtained through the sub-control texts pre-recorded in the preset array; the maximum text width is assigned to the test control, and the maximum number of second text lines in each sub-control is obtained.
[0011] This implementation method obtains the text width of each sub-control by pre-recording the text of each sub-control in a preset array, and then assigns the largest text width to the test control to obtain the maximum number of second text lines. When the Segment control to be configured is vertical layout, the number of sub-control text lines in horizontal layout is obtained, thereby helping to determine whether the maximum second number of text lines is less than the maximum number of horizontal lines, and being more intelligent in determining whether the Segment control meets the conditions for switching to horizontal layout.
[0012] In some implementations of the first aspect, the Segment control to be configured is in a parent container area, and switching the current layout direction to a horizontal layout includes:
[0013] Remove the child control and update the height of the child control according to the height of the parent container so that the height of the child control fills the parent container; add the child control with updated height back to the Segment control to be configured, so as to switch the layout direction of the Segment control to be configured to a horizontal layout.
[0014] When the Segment control to be configured is switched to a horizontal layout, this implementation sets the height of the child control to fill the height of the parent container, so that the height of the child control also changes when the Segment control of the application interface is switched to a horizontal layout, thereby improving the aesthetics of the application interface and conforming to the user's aesthetic taste.
[0015] In some implementations of the first aspect, the Segment control to be configured is in a parent container area; and switching the current layout direction to a vertical layout includes:
[0016] Remove the child control and update the width of the child control according to the width of the parent container so that the width of the child control fills the parent container; add the child control with updated width back to the Segment control to be configured, so as to switch the layout direction of the Segment control to be configured to a vertical layout.
[0017] When the layout direction of the Segment control to be configured is switched to a vertical layout, this implementation sets the width of the child control to fill the width of the parent container, so that the width of the child control also changes when the Segment control of the application interface is switched to a vertical layout, thereby improving the aesthetics of the application interface and conforming to user aesthetics.
[0018] In some implementations of the first aspect, the Segment control to be configured is in a parent container area of the application interface, and the Segment control configuration method further includes:
[0019] When the interface size of the application interface changes, determining the size relationship between the sum of the widths of each sub-control and the width of the parent container; wherein the widths of each sub-control and the width of the parent container are both adapted to the interface size;
[0020] When the width of the parent container is greater than the sum of the widths of the child controls, the width of the Segment control to be configured is adjusted according to the mapping relationship between the parent container and the Segment control to be configured.
[0021] When the interface size of the application interface changes, this implementation method determines the size relationship between the sum of the widths of each child control and the width of the parent container. When the width of the parent container is greater than the sum of the widths of the child controls, the width of the Segment control is adjusted according to the mapping relationship between the parent container and the Segment control to be configured. The width of the Segment control changes adaptively with the change of the interface size. The width of the Segment control can be coordinated with the interface size to meet the needs of application interfaces of different sizes.
[0022] In some implementations of the first aspect, the mapping relationship includes a scale parameter; and adjusting the width of the Segment control to be configured according to the mapping relationship between the parent container and the Segment control to be configured includes:
[0023] Calculate the size information according to the ratio parameter and the width of the parent container that is adapted to the interface size;
[0024] The expected width of the Segment control to be configured is determined according to the size information, so that the parent container is cropped according to the expected width to obtain the Segment control to be configured with an adjusted width.
[0025] The mapping relationship of this implementation method is specifically a proportional parameter. According to the proportional parameter and the width of the parent container that is adapted to the interface size, the size information is calculated to determine the width of the Segment control, thereby further improving the degree of adaptation between the width of the Segment control and the interface size. The same proportional parameter can be maintained in interfaces of different sizes without affecting the user's perception.
[0026] In some implementations of the first aspect, determining the expected width of the Segment control to be configured according to the size information includes:
[0027] Acquiring mode information, wherein the mode information matches the interface size;
[0028] generating a comprehensive value according to the mode information and the size information;
[0029] According to the comprehensive value, the expected width of the Segment control to be configured is determined.
[0030] This implementation method generates a comprehensive value based on the mode information and size information, so that the expected width of the Segment control matches the mode information and size information. The generated comprehensive value can also be called by subsequent steps to facilitate the next adjustment of the Segment control width.
[0031] In some implementations of the first aspect, determining the current layout direction of the Segment control to be configured includes:
[0032] In response to the application startup operation, obtain the first interface information that needs to be displayed when the application is started;
[0033] According to the first interface information, the current layout direction of the Segment control to be configured is determined.
[0034] In some implementations of the first aspect, determining the current layout direction of the Segment control to be configured includes:
[0035] Respond to the interface switching operation and obtain the second interface information to be displayed after the interface switching;
[0036] According to the second interface information, the current layout direction of the Segment control to be configured is determined.
[0037] The second aspect of the present invention application provides a Segment control configuration device, including a layout direction determination module, a vertical layout module and a horizontal layout module; wherein,
[0038] The layout direction determination module is used to determine the current layout direction of the Segment control to be configured, and the Segment control to be configured includes multiple sub-controls;
[0039] The vertical layout module is used to obtain the first text line number of each sub-control when the current layout direction is horizontal layout; and when the maximum first text line number is greater than the preset maximum line number of horizontal version, switch the layout direction of the Segment control to be configured to vertical layout;
[0040] The horizontal layout module is used to obtain the maximum number of second text lines in each sub-control through a preset test control when the current layout direction is a vertical layout; and when the maximum number of second text lines is less than the maximum number of lines in the horizontal version, switch the layout direction of the Segment control to be configured to a horizontal layout; the control parameters of the test control are the same as the sub-control parameters when the layout direction of the Segment control to be configured is a horizontal layout.
[0041] In some implementations of the second aspect, the horizontal layout module includes a value assignment unit, where the value assignment unit is used to:
[0042] The preset array is traversed and accessed, and the text width of each sub-control is obtained through the sub-control texts pre-recorded in the preset array; the maximum text width is assigned to the test control, and the maximum number of second text lines in each sub-control is obtained.
[0043] In some implementations of the second aspect, the Segment control to be configured is in a parent container area, and the horizontal layout module includes a first child control configuration unit, which is used to:
[0044] Remove the child control and update the height of the child control according to the height of the parent container so that the height of the child control fills the parent container; add the child control with updated height back to the Segment control to be configured, so as to switch the layout direction of the Segment control to be configured to a horizontal layout.
[0045] In some implementations of the second aspect, the Segment control to be configured is in a parent container area, and the vertical layout module includes a second child control configuration unit, where the second child control configuration unit is used to:
[0046] Remove the child control and update the width of the child control according to the width of the parent container so that the width of the child control fills the parent container; add the child control with updated width back to the Segment control to be configured, so as to switch the layout direction of the Segment control to be configured to a vertical layout.
[0047] In some implementations of the second aspect, the Segment control to be configured is in a parent container area of the application interface, and the Segment control configuration device further includes a width adjustment module:
[0048] The width adjustment module is used to determine the size relationship between the sum of the widths of each sub-control and the width of the parent container when the interface size of the application interface changes; wherein the widths of each sub-control and the width of the parent container are both adapted to the interface size;
[0049] When the width of the parent container is greater than the sum of the widths of the child controls, the width of the Segment control to be configured is adjusted according to the mapping relationship between the parent container and the Segment control to be configured.
[0050] In some implementations of the second aspect, the mapping relationship includes a scale parameter; the width adjustment module includes a cropping unit, and the cropping unit is used to:
[0051] Calculate the size information according to the ratio parameter and the width of the parent container that is adapted to the interface size;
[0052] The expected width of the Segment control to be configured is determined according to the size information, so that the parent container is cropped according to the expected width to obtain the Segment control to be configured with an adjusted width.
[0053] In some implementations of the second aspect, the width adjustment module includes an expected width determination unit, where the expected width determination unit is configured to:
[0054] Acquiring mode information, wherein the mode information matches the interface size;
[0055] generating a comprehensive value according to the mode information and the size information;
[0056] According to the comprehensive value, the expected width of the Segment control to be configured is determined.
[0057] In some implementations of the second aspect, the layout direction determining module includes a first layout direction determining unit, and the first layout direction determining unit is configured to:
[0058] In response to the application startup operation, obtain the first interface information that needs to be displayed when the application is started;
[0059] According to the first interface information, the current layout direction of the Segment control to be configured is determined.
[0060] In some implementations of the second aspect, the layout direction determining module includes a second layout direction determining unit, and the second layout direction determining unit is configured to:
[0061] Respond to the interface switching operation and obtain the second interface information to be displayed after the interface switching;
[0062] According to the second interface information, the current layout direction of the Segment control to be configured is determined.
[0063] The third aspect of the present application provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and the processor implements the Segment control configuration method when executing the computer program.
[0064] The fourth aspect of the present application provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the Segment control configuration method. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 : A flow chart of an implementation of the Segment control configuration method provided in the present application.
[0066] Figure 2 : A schematic diagram of the effect of an implementation of the Segment control provided in the present application.
[0067] Figure 3 : A schematic diagram of the effect of an implementation of the horizontal layout of the Segment controls provided in the present application.
[0068] Figure 4 : A schematic diagram of the effect of an implementation of the vertical layout of Segment controls provided in the present application.
[0069] Figure 5 : A schematic diagram of the effect of an implementation of the Segment control at 2 / 3 screen size of the application interface provided by the present invention.
[0070] Figure 6 : A schematic diagram of the effect of an implementation method of a Segment control configuration method in a full-screen size of an application interface provided by the prior art.
[0071] Figure 7 : A schematic diagram of the effect of an implementation method of the Segment control configuration method in full screen size of the application interface provided by the present invention.
[0072] Figure 8 : A structural diagram of an implementation scheme of the Segment control configuration device provided in the present application.
[0073] Fig. 9 : A structural diagram of another implementation of the Segment control configuration device provided in the present application. DETAILED DESCRIPTION
[0074] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0075] Embodiment 1
[0076] Please refer to Figure 1 , Figure 1 The present invention provides a Segment control configuration method, which can be applied to terminal devices, including but not limited to smart phones, laptops, tablet computers, desktop computers or vehicle terminals. Figure 1 As shown, the Segment control configuration method of this embodiment includes steps S101 to S103, which are described in detail as follows:
[0077] Step S101, determining the current layout direction of a Segment control to be configured, wherein the Segment control to be configured includes a plurality of sub-controls.
[0078] Among them, the Segment control is a segmented control that is widely used in various types of UI interfaces. It can provide interface switching functions by providing tabs / sub-controls in each segment. The relationship between the Segment control and the sub-controls is as follows: Figure 2 The width of the sub-control is related to the ease of use. The wider the sub-control, the easier it is to click. Conversely, the narrower the sub-control, the more sub-controls or tabs the Segment control can provide in the same size application interface, providing users with multiple options in the same application interface to support the interface switching function corresponding to each option.
[0079] The layout directions of the Segment control include horizontal layout and vertical layout. As recorded in the relevant technology, in the application interface, the layout and size of the Segment control and its sub-controls are often fixed. Therefore, in some application scenarios, the layout direction of the sub-control text will not match the layout direction. For example, the same semantics requires two characters when the sub-control text is in Chinese, but some small languages may require up to eight characters. At this time, the horizontally laid out Segment control obviously cannot meet the demand and will affect the user experience. This step determines the corresponding execution of subsequent steps by determining the current layout direction of the Segment control to be configured. For example, when the current layout direction is horizontal, execute step S102; when the current layout direction is vertical, execute step S103.
[0080] In some embodiments, the determination of the current layout direction of the Segment control to be configured in step S101 may include: responding to the application startup operation, obtaining the first interface information of the interface to be displayed when the application is started; and determining the current layout direction of the Segment control to be configured based on the first interface information. Taking into account some application scenarios, such as the application startup scenario, there are configuration requirements for the Segment control when the user first opens the application interface. For example, the sub-control text was displayed in Chinese when the application was started last time, and the user reopened the application again when English or other small languages were selected. At this time, it is necessary to determine the layout direction of the Segment control at the current moment. This embodiment determines the current layout direction of the Segment control to be configured through the first interface information. The first interface information may be the information retained when the application was last closed, and the current layout direction may also correspond to the layout direction retained when the application was last closed.
[0081] In other embodiments, determining the current layout direction of the Segment control to be configured includes: responding to an interface switching operation, obtaining second interface information to be displayed after the interface switching; and determining the current layout direction of the Segment control to be configured based on the second interface information. In other application scenarios, for the same application, there may be a parent tab for the Segment control to be configured, and the parent tab is used to implement the switching from the first interface to the second interface. The Segment control to be configured exists in the second interface after the switching. Based on the second interface information, the current layout direction of the configured Segment control can be determined, and the current layout direction can be the layout direction retained when the second interface was closed last time.
[0082] Step S102, when the current layout direction is horizontal layout, respectively obtain the first text line number of each sub-control; and when the maximum first text line number is greater than the preset horizontal version maximum line number, switch the layout direction of the Segment control to be configured to vertical layout.
[0083] In this step, the relationship between the Segment control and its child controls and parent container is as follows: Figure 2 When the current layout direction is horizontal, the first text line number of each sub-control in the Segment control to be configured can be directly obtained; and the maximum of the first text line numbers is compared with the preset horizontal maximum line number. When the first text line number is greater than the horizontal maximum line number, the layout direction of the Segment control to be configured is switched to vertical layout.
[0084] The effect of switching the layout direction of the Segment control to be configured from horizontal layout to vertical layout is shown in the figure below. Figure 3 and Figure 4 shown. Figure 3 In one implementation shown, the preset maximum number of horizontal lines can be "2", while the maximum number of first text lines in each sub-control is currently "3". At this time, only half of the last line of text can be displayed, resulting in an incomplete display problem. Therefore, the present application adaptively switches the layout direction of the Segment control to be configured to a vertical layout, so that the text of the sub-control is fully displayed.
[0085] Considering that the Segment control inherits the LineLayout layout, in some implementations, the Segment control to be configured is in the parent container area; the switching of the current layout direction to a vertical layout includes:
[0086] Remove the child control and update the width of the child control according to the width of the parent container so that the width of the child control fills the parent container; add the child control with updated width back to the Segment control to be configured, so as to switch the layout direction of the Segment control to be configured to a vertical layout.
[0087] Among them, the width of the child control is filled with the parent container, that is, the property of the child control is modified to "width fills parent container". At this time, the height of the child control can be modified to be equally divided, so that the child control can be added back to the Segment control. At this time, the Segment control is more beautiful in subsequent display, which can effectively improve the user experience.
[0088] Step S103, when the current layout direction is a vertical layout, obtain the maximum number of second text lines in each sub-control through a preset test control; and when the maximum number of second text lines is less than the maximum number of horizontal lines, switch the layout direction of the Segment control to be configured to a horizontal layout.
[0089] Among them, the test control can be pre-constructed before step S103, and the control parameters of the test control are the same as the sub-control parameters when the layout direction of the Segment control to be configured is horizontal layout (including but not limited to length, width, font size, font style and left and right spacing, etc.). In this way, when the current layout direction of the Segment control to be configured is vertical layout, the test control can be used to simulate the sub-controls in the horizontal layout, so as to obtain the second number of text lines in each sub-control, and determine whether the conditions for switching the layout direction of the Segment control to be configured to the horizontal layout are met through the number of text lines. The effect of switching the layout direction of the Segment control to be configured from vertical layout to horizontal layout is as follows: Figure 4 and Figure 3 shown.
[0090] In some implementations, an array may be pre-built before step S103, and the text information of each sub-control may be recorded in the array to facilitate subsequent calls to the array. The method of obtaining the maximum number of second text lines in each sub-control through a preset test control includes: traversing and accessing the array, obtaining the text width of each sub-control through the text of each sub-control pre-recorded in the preset array, and using the "measureText() function" provided by Android to obtain the text width of each sub-control; assigning the maximum text width to the test control, obtaining the number of second text lines of each sub-control through the getLineCount() function, and then obtaining the maximum number of second text lines among them.
[0091] In this way, the text widths of the sub-controls are obtained respectively through the text pre-recorded in the preset array, and the largest text width is assigned to the test control to obtain the maximum number of second text lines. When the Segment control to be configured is vertically laid out, the number of sub-control text lines in horizontal layout is obtained, thereby helping to determine whether the maximum number of second text lines is less than the maximum number of horizontal lines, and being more intelligent in determining whether the Segment control meets the conditions for switching to horizontal layout.
[0092] In some implementations, the Segment control to be configured is in a parent container area, and switching the current layout direction to a horizontal layout includes:
[0093] Remove the child control and update the height of the child control according to the height of the parent container so that the height of the child control fills the parent container; add the child control with updated height back to the Segment control to be configured, so as to switch the layout direction of the Segment control to be configured to a horizontal layout.
[0094] Among them, the height of the child control is filled with the parent container, that is, the property of the child control is modified to "height fills parent container". When the Segment control of the application interface is switched to a horizontal layout, the child control also changes accordingly, thereby improving the aesthetics of the application interface and conforming to the user's aesthetic taste. At the same time, this implementation method can modify the width of the child control to be equally divided, and then add the child control back to the Segment control. At this time, the Segment control is more beautiful in subsequent displays, which can effectively improve the user's viewing experience.
[0095] Considering that the layout and size of the Segment control and its sub-controls in the prior art are often fixed, and as the number of screen types increases, the sizes of different types of screens are diversified. Similarly, the sizes of different application interfaces on the same screen will also be diversified (such as applications in full screen and 2 / 3 screen sizes). The sizes of the Segment control and its sub-controls should also be adapted to these diverse application interfaces. In some preferred embodiments, the Segment control to be configured is in the parent container area of the application interface, and the Segment control configuration method further includes:
[0096] When the interface size of the application interface changes, the size relationship between the sum of the widths of the child controls and the width of the parent container is determined; wherein the widths of the child controls and the width of the parent container are both adapted to the interface size.
[0097] When the width of the parent container is greater than the sum of the widths of the child controls, the width of the Segment control to be configured is adjusted according to the mapping relationship between the parent container and the Segment control to be configured.
[0098] Each time the onMeasure() function is entered, the sum of the widths of the child controls can be measured, and the width of the Segment given by the parent container can be used to adjust the width of the Segment control to be configured according to the above mapping relationship.
[0099] The actual effect is as follows Figures 5 to 7 As shown, Figure 5 What is shown is the 2 / 3 screen status effect diagram. Figure 6 The effect diagram of the fixed value of the full screen state (the method commonly used in the prior art), Figure 7It is a full-screen adaptive effect diagram (using the mapping relationship between the parent container and the Segment control to be configured). It can be understood that whether it is full screen or 2 / 3 screen, the size of the parent container changes with the switching between full screen and 2 / 3 screen. If the fixed value mode is used, then in the full screen state, the Segment control will look inconsistent, which affects the user's perception.
[0100] As a further preferred implementation, the mapping relationship includes a scale parameter; and adjusting the width of the Segment control to be configured according to the mapping relationship between the parent container and the Segment control to be configured includes:
[0101] The size information is calculated according to the proportion parameter and the width of the parent container that is compatible with the interface size; the expected width of the Segment control to be configured is determined according to the size information, and the parent container is cropped according to the expected width to obtain the Segment control to be configured with an adjusted width.
[0102] Exemplarily, the ratio parameter may indicate that the Segment control is 75% of the parent container. The size information of the Segment control can be calculated by the ratio parameter and the width of the parent container adapted to the interface size, so that no matter how the parent container size, application interface size or screen size changes, it can be displayed according to the ratio parameter.
[0103] In some implementations, determining the expected width of the Segment control to be configured according to the size information includes:
[0104] Acquire mode information, the mode information matching the interface size; generate a comprehensive value based on the mode information and the size information; and determine the expected width of the Segment control to be configured based on the comprehensive value.
[0105] After obtaining the above size information, you can select the EXACTLY mode of MeasureSpec, and use the makeMeasureSpec() function to obtain a comprehensive value containing size information and mode information. The comprehensive value is a system-provided attribute. For example, the first two digits of the comprehensive value can represent the mode, and the last two digits can represent the size. Passing the comprehensive value to the super.onMeasure() function can complete the cropping and assign the width to the Segment control. The generated comprehensive value can be used to update the initial comprehensive value, so that the Segment control size can call the latest comprehensive value the next time it is adjusted, without the need for additional code.
[0106] like Figure 8As shown, the present invention also provides a Segment control configuration device, including a layout direction determination module 801, a vertical layout module 802 and a horizontal layout module 803; wherein,
[0107] The layout direction determination module 801 is used to determine the current layout direction of the Segment control to be configured, where the Segment control to be configured includes multiple sub-controls;
[0108] The vertical layout module 802 is used to obtain the first text line number of each sub-control when the current layout direction is horizontal layout; and when the maximum first text line number is greater than the preset horizontal maximum line number, switch the layout direction of the Segment control to be configured to vertical layout;
[0109] The horizontal layout module 803 is used to obtain the maximum number of second text lines in each sub-control through a preset test control when the current layout direction is a vertical layout; and when the maximum number of second text lines is less than the maximum number of horizontal lines, switch the layout direction of the Segment control to be configured to a horizontal layout; the control parameters of the test control are the same as the sub-control parameters when the layout direction of the Segment control to be configured is a horizontal layout.
[0110] In some preferred implementations, the horizontal layout module 803 includes a value assignment unit, which is used to:
[0111] The preset array is traversed and accessed, and the text width of each sub-control is obtained through the sub-control texts pre-recorded in the preset array; the maximum text width is assigned to the test control, and the maximum number of second text lines in each sub-control is obtained.
[0112] In some preferred implementations, the Segment control to be configured is in the parent container area, and the horizontal layout module 803 includes a first child control configuration unit, and the first child control configuration unit is used to:
[0113] Remove the child control and update the height of the child control according to the height of the parent container so that the height of the child control fills the parent container; add the child control with updated height back to the Segment control to be configured, so as to switch the layout direction of the Segment control to be configured to a horizontal layout.
[0114] In some preferred implementations, the Segment control to be configured is in the parent container area, and the vertical layout module 802 includes a second sub-control configuration unit, and the second sub-control configuration unit is used to:
[0115] Remove the child control and update the width of the child control according to the width of the parent container so that the width of the child control fills the parent container; add the child control with updated width back to the Segment control to be configured, so as to switch the layout direction of the Segment control to be configured to a vertical layout.
[0116] In some preferred embodiments, Fig. 9 As shown, the Segment control to be configured is in the parent container area of the application interface, and the Segment control configuration device further includes a width adjustment module 804:
[0117] The width adjustment module 804 is used to determine the size relationship between the sum of the widths of each sub-control and the width of the parent container when the interface size of the application interface changes; wherein the widths of each sub-control and the width of the parent container are both adapted to the interface size;
[0118] When the width of the parent container is greater than the sum of the widths of the child controls, the width of the Segment control to be configured is adjusted according to the mapping relationship between the parent container and the Segment control to be configured.
[0119] In some preferred implementations, the mapping relationship includes a scale parameter; the width adjustment module 804 includes a cropping unit, and the cropping unit is used to:
[0120] Calculate the size information according to the ratio parameter and the width of the parent container that is adapted to the interface size;
[0121] The expected width of the Segment control to be configured is determined according to the size information, so that the parent container is cropped according to the expected width to obtain the Segment control to be configured with an adjusted width.
[0122] In some preferred embodiments, the width adjustment module 804 includes an expected width determination unit, and the expected width determination unit is used to:
[0123] Acquiring mode information, wherein the mode information matches the interface size;
[0124] generating a comprehensive value according to the mode information and the size information;
[0125] According to the comprehensive value, the expected width of the Segment control to be configured is determined.
[0126] In some preferred implementations, the layout direction determining module 801 includes a first layout direction determining unit, and the first layout direction determining unit is used to:
[0127] In response to the application startup operation, obtain the first interface information that needs to be displayed when the application is started;
[0128] According to the first interface information, the current layout direction of the Segment control to be configured is determined.
[0129] In some preferred implementations, the layout direction determining module 801 includes a second layout direction determining unit, and the second layout direction determining unit is used to:
[0130] Respond to the interface switching operation and obtain the second interface information to be displayed after the interface switching;
[0131] According to the second interface information, the current layout direction of the Segment control to be configured is determined.
[0132] In addition, the present application also provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and the processor implements the Segment control configuration method when executing the computer program.
[0133] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the terminal, and various interfaces and lines are used to connect various parts of the entire terminal.
[0134] The memory can be used to store the computer program, and the processor realizes various functions of the terminal by running or executing the computer program stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Medi a Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (F l ash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0135] In addition, the present application also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the Segment control configuration method.
[0136] Among them, if the module integrated in the Segment control configuration device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.
[0137] Compared with the prior art, the present invention applies that when the current layout direction is horizontal layout, when the largest number of first text lines in each sub-control is greater than the preset maximum number of horizontal lines, the layout direction of the Segment control is switched to vertical layout, so as to avoid the problem of incomplete display of sub-control text; when the current layout direction is vertical, when the largest number of second text lines in each sub-control is less than the said maximum number of horizontal lines, the layout direction of the Segment control to be configured is switched to horizontal, and the application interface is more concise, so that the Segment control layout can be adaptively switched according to the number of text lines in the sub-control, thereby improving the adaptability of the Segment control in different layouts and enhancing the user experience.
[0138] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of protection of the present invention.
Claims
1. A Segment control configuration method, characterized in that: include: Determine the current layout direction of the Segment control to be configured, where the Segment control to be configured includes multiple sub-controls; When the current layout direction is horizontal layout, the first text line number of each sub-control is obtained respectively; and when the maximum first text line number is greater than the preset horizontal maximum line number, the layout direction of the Segment control to be configured is switched to vertical layout; When the current layout direction is a vertical layout, the maximum number of second text lines in each sub-control is obtained through a preset test control; and when the maximum number of second text lines is less than the maximum number of lines in the horizontal version, the layout direction of the Segment control to be configured is switched to a horizontal layout; the control parameters of the test control are the same as the sub-control parameters when the layout direction of the Segment control to be configured is a horizontal layout.
2. A Segment control configuration method according to claim 1, characterized in that: The method of obtaining the maximum number of second text lines in each sub-control through a preset test control includes: The preset array is traversed and accessed, and the text width of each sub-control is obtained through the sub-control texts pre-recorded in the preset array; the maximum text width is assigned to the test control, and the maximum number of second text lines in each sub-control is obtained.
3. A Segment control configuration method as claimed in claim 1, characterized in that: The Segment control to be configured is in the parent container area, and the switching of the current layout direction to a horizontal layout includes: Remove the child control and update the height of the child control according to the height of the parent container so that the height of the child control fills the parent container; add the child control with updated height back to the Segment control to be configured, so as to switch the layout direction of the Segment control to be configured to a horizontal layout.
4. A Segment control configuration method according to claim 1, characterized in that: The Segment control to be configured is in the parent container area; and the switching of the current layout direction to a vertical layout includes: Remove the child control and update the width of the child control according to the width of the parent container so that the width of the child control fills the parent container; add the child control with updated width back to the Segment control to be configured, so as to switch the layout direction of the Segment control to be configured to a vertical layout.
5. A Segment control configuration method as claimed in claim 1, characterized in that: The Segment control to be configured is in the parent container area of the application interface, and the Segment control configuration method further includes: When the interface size of the application interface changes, determining the size relationship between the sum of the widths of each sub-control and the width of the parent container; wherein the widths of each sub-control and the width of the parent container are both adapted to the interface size; When the width of the parent container is greater than the sum of the widths of the child controls, the width of the Segment control to be configured is adjusted according to the mapping relationship between the parent container and the Segment control to be configured.
6. A Segment control configuration method as claimed in claim 5, characterized in that: The mapping relationship includes a scale parameter; and adjusting the width of the Segment control to be configured according to the mapping relationship between the parent container and the Segment control to be configured includes: Calculate the size information according to the ratio parameter and the width of the parent container that is adapted to the interface size; The expected width of the Segment control to be configured is determined according to the size information, so that the parent container is cropped according to the expected width to obtain the Segment control to be configured with an adjusted width.
7. A Segment control configuration method as claimed in claim 6, characterized in that: The determining the expected width of the Segment control to be configured according to the size information includes: Acquiring mode information, wherein the mode information matches the interface size; generating a comprehensive value according to the mode information and the size information; According to the comprehensive value, the expected width of the Segment control to be configured is determined.
8. A Segment control configuration method as claimed in claim 1, characterized in that: The determining the current layout direction of the Segment control to be configured includes: In response to the application startup operation, obtain the first interface information that needs to be displayed when the application is started; According to the first interface information, the current layout direction of the Segment control to be configured is determined.
9. A Segment control configuration method as claimed in claim 1, characterized in that: The determining the current layout direction of the Segment control to be configured includes: Respond to the interface switching operation and obtain the second interface information to be displayed after the interface switching; According to the second interface information, the current layout direction of the Segment control to be configured is determined.
10. A Segment control configuration device, characterized in that: It includes a layout direction determination module, a vertical layout module and a horizontal layout module; wherein, The layout direction determination module is used to determine the current layout direction of the Segment control to be configured, and the Segment control to be configured includes multiple sub-controls; The vertical layout module is used to obtain the first text line number of each sub-control when the current layout direction is horizontal layout; and when the maximum first text line number is greater than the preset maximum line number of horizontal version, switch the layout direction of the Segment control to be configured to vertical layout; The horizontal layout module is used to obtain the maximum number of second text lines in each sub-control through a preset test control when the current layout direction is a vertical layout; and when the maximum number of second text lines is less than the maximum number of lines in the horizontal version, switch the layout direction of the Segment control to be configured to a horizontal layout; the control parameters of the test control are the same as the sub-control parameters when the layout direction of the Segment control to be configured is a horizontal layout.
11. A terminal device, characterized in that: It includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, it implements the Segment control configuration method as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the Segment control configuration method as described in any one of claims 1 to 9.
Citation Information
Cited By
Page layout method, page layout device and computer storage medium
CN119225896A
A page layout method, page layout device and computer storage medium
CN119225896B
