Focus centering method, storage medium and electronic equipment
By monitoring focus changes and sliding content in the parent control of the Android smart TV, the problem of missing focus and single content is solved, and the centering and diversified compatibility of focus is achieved, and the user experience is improved.
Patent Information
- Application Number
- CN202411411360.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-15
- Publication Date
- 2024-12-27
AI Technical Summary
Existing Android smart TVs lack focus centering strategies, resulting in easy loss of focus and single display content, poor user experience, and native controls cannot be compatible with diverse display content.
By adding swipable content to the parent control and monitoring focus changes, and calling back the specified value to obtain the sliding value, the parent control slides the swiping content, ensuring that the focus is horizontal or vertical center, compatible with diverse display content.
It realizes a focus centering strategy, and is compatible with diversified display content, improves user experience, and simplifies code implementation and promotion.
Smart Images

Figure CN119211617A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of focus processing technology, and in particular to a focus centering method, a storage medium and an electronic device. Background Art
[0002] With the advancement of intelligent technology, more and more smart home devices are developed in the existing technology, and users use smart home devices more and more frequently in their daily lives.
[0003] In the prior art, when users use an Android smart TV, the smart TV does not have a focus centering strategy, which causes the focus of the smart TV to be easily lost and the displayed image to flicker. At the same time, the native controls of the Android system are not compatible with the diversity of displayed content, resulting in a single size and layout of the displayed content, and thus the user experience is still poor.
[0004] In order to improve the focus loss problem of smart TVs, the Android system has developed the native control VerticalGridView for horizontal centering and the native control HorizontalGridView for vertical centering. However, the native controls VerticalGridView and HorizontalGridView are too closed and still cannot be compatible with the diversification of displayed content, so the user experience is still poor. Summary of the invention
[0005] The technical problem solved by the present invention is to provide a focus centering method, so that an electronic device using an Android system can take into account both focus centering and diversification of display content, so as to improve user experience.
[0006] To solve the above technical problems, the technical solution of the present invention provides a method for centering focus, comprising: adding a plurality of slidable contents to a parent control, the parent control being a slidable control, the parent control comprising a first specified boundary and a display area, the first specified boundary being parallel or perpendicular to a sliding direction of the plurality of slidable contents, the display area comprising a second specified boundary, the second specified boundary being parallel to and adjacent to the first specified boundary; when it is monitored that the focus changes from the original focus to the current focus in the plurality of slidable contents, the first specified value of the current focus, the second specified value of the current focus, the first specified value of the original focus and the third specified value of the original focus are called back, wherein the first specified value is the slidable the minimum distance between the edge of the slidable content and the first specified boundary, the second specified value is the maximum distance between the edge of the slidable content and the first specified boundary, and the third specified value is the minimum distance between the edge of the slidable content and the second specified boundary; according to the first specified value of the current focus, the second specified value of the current focus, the first specified value of the original focus, the third specified value of the original focus, and the size of the display area in the direction perpendicular to the first specified boundary, the first sliding value is obtained; when it is monitored that the focus changes from the original focus to the current focus in several slidable contents, the parent control slides the several slidable contents in the direction perpendicular to the first specified boundary according to the first sliding value.
[0007] The technical solution of the present invention further provides a storage medium on which computer instructions are stored. When the computer instructions are executed by a processor, the focus centering method described above is implemented.
[0008] The technical solution of the present invention also provides an electronic device, including a processor, a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to implement instructions for the steps in the focus centering method as described above when executed by the processor.
[0009] Compared with the prior art, the technical solution of the embodiment of the present invention has the following beneficial effects:
[0010] In the method for centering the focus provided by the technical solution of the present invention, the first sliding value is used to slide the position of the current focus to the horizontal center or vertical center of the display area. Since in the method for centering the focus, when the focus is monitored to change from the original focus to the current focus in several slidable contents, the first specified value of the current focus, the second specified value of the current focus, the first specified value of the original focus and the third specified value of the original focus are called back to obtain the first sliding value, and the parent control slides the several slidable contents according to the first sliding value, therefore, while implementing the centering strategy, a parent control that can be compatible with diversified display contents (slidable contents) can be adopted. Thus, through the method for centering the focus, electronic devices using the Android system can take into account the centering and diversification of the display contents, thereby improving the user experience. Specifically, in the method for centering the focus, through the native monitoring class of the Android system, on the one hand, it is possible to realize the focus changes of several slidable contents, and on the other hand, it is possible to realize the callback of the first specified value, the second specified value, and the third specified value of any slidable content to obtain the first sliding value, therefore, through simple calculations and a small amount of data interaction, the centering strategy of the current focus can be realized when the focus changes. On this basis, the focus centering method can be used as a centering strategy for any slidable control, so that the types of parent controls for slidable controls are less restricted. Therefore, existing parent controls that are compatible with a variety of display content can be used. Thus, the focus centering method can enable electronic devices using the Android system to take into account both focus centering and diversification of display content. Not only that, because the focus centering method can implement the current focus centering strategy through the native listening class of the Android system and the existing parent controls that are compatible with a variety of display content, the focus centering method is easy to implement and promote. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 is a flow chart of a method for centering focus according to an embodiment of the present invention;
[0012] Figure 2 is a schematic diagram of slidable content and a parent control in one embodiment of the present invention;
[0013] Figure 3 is a schematic diagram of an original focus and a current focus in one embodiment of the present invention;
[0014] Figure 4 is a flow chart of a method for obtaining a first sliding value in one embodiment of the present invention;
[0015] Figure 5 is a schematic diagram of the relationship between a first sliding value and a first position of a current focus in one embodiment of the present invention;
[0016] Figure 6is a schematic diagram of the relationship between the first sliding value and the second position of the current focus in one embodiment of the present invention;
[0017] Figure 7 is a flowchart of a method for sliding a plurality of slidable contents according to a first sliding value in one embodiment of the present invention;
[0018] Figure 8 is a schematic diagram of a first sliding of the focus in a direction perpendicular to the first designated boundary in one embodiment of the present invention;
[0019] Fig. 9 is a schematic diagram of a second sliding of the focus in a direction perpendicular to the first designated boundary in one embodiment of the present invention;
[0020] Fig.10 is a flow chart of a method for obtaining a second sliding value in one embodiment of the present invention;
[0021] Fig.11 is a schematic diagram of the relationship between the second sliding value and the first position of the current focus in one embodiment of the present invention;
[0022] Fig.12 is a schematic diagram of a second position relationship between a second sliding value and a current focus in one embodiment of the present invention;
[0023] Fig.13 is a flowchart of a method for sliding a plurality of slidable contents according to a second sliding value in one embodiment of the present invention;
[0024] Fig.14 is a schematic diagram of a first sliding of the focus in a direction parallel to the first designated boundary in one embodiment of the present invention;
[0025] Fig.15 It is a schematic diagram of a second sliding of the focus in a direction parallel to the first designated boundary in one embodiment of the present invention. DETAILED DESCRIPTION
[0026] As described in the background art, in the prior art, smart TVs using the Android system cannot achieve centering of the current focus while taking into account the diversification of displayed content, so the user experience is still poor.
[0027] In order to solve the above technical problems, the technical solution of the present invention provides a focus centering method, storage medium, and electronic device, which monitors the focus changes in a number of slidable contents, and when it is monitored that the focus changes from the original focus to the current focus in the number of slidable contents, the first specified value of the current focus, the second specified value of the current focus, the first specified value of the original focus, and the third specified value of the original focus are called back to obtain the first sliding value, and the parent control slides the number of slidable contents according to the first sliding value, so that electronic devices using the Android system can take into account both the focus centering and the diversification of the displayed content, thereby improving the user experience.
[0028] In order to make the above-mentioned objects, features and beneficial effects of the present invention more obvious and easy to understand, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0029] Figure 1 4 is a flow chart of a method for centering focus according to an embodiment of the present invention.
[0030] The execution side of the solution in this embodiment is an electronic device using the Android system.
[0031] Specifically, the electronic device includes a smart TV using the Android system.
[0032] Please refer to Figure 1 , the focus centering method includes:
[0033] Step S100, adding a plurality of slidable contents to a parent control, wherein the parent control includes a first specified boundary, a third specified boundary and a display area;
[0034] Step S200, when it is monitored that the focus changes from the original focus to the current focus in the plurality of slidable contents, the first specified value of the current focus, the second specified value of the current focus, the first specified value of the original focus, and the third specified value of the original focus are called back;
[0035] Step S300, obtaining a first sliding value according to a first specified value of the current focus, a second specified value of the current focus, a first specified value of the original focus, a third specified value of the original focus, and a size of the display area in a direction perpendicular to the first specified boundary;
[0036] Step S400, when it is monitored that the focus changes from the original focus to the current focus in the plurality of slidable contents, the parent control slides the plurality of slidable contents in a direction perpendicular to the first designated boundary according to the first sliding value;
[0037] Step S500, when it is monitored that the focus changes from the original focus to the current focus in the plurality of slidable contents, the fourth specified value of the current focus, the fifth specified value of the current focus, the fourth specified value of the original focus, and the sixth specified value of the original focus are called back;
[0038] Step S600, obtaining a second sliding value according to a fourth designated value of the current focus, a fifth designated value of the current focus, a fourth designated value of the original focus, a sixth designated value of the original focus, and a size of the display area in a direction parallel to the first designated boundary;
[0039] Step S700: When it is monitored that the focus changes from the original focus to the current focus in a plurality of slidable contents, the parent control slides the plurality of slidable contents in a direction parallel to the first designated boundary according to the second sliding value.
[0040] The following is a detailed description with reference to the accompanying drawings.
[0041] Please refer to Figure 1 and Figure 2 , Figure 2 It is a schematic diagram of slidable content and a parent control in an embodiment of the present invention. Step S100 is executed to add a plurality of slidable contents 200 to a parent control. The parent control includes a first designated boundary 101 , a third designated boundary 102 and a display area 110 .
[0042] The slidable content 200 refers to content that can be slidably displayed in an electronic device, for example, a logo of an application, several titles corresponding to various functions, a video name, etc.
[0043] It is important to understand that Figure 2 Only part of the slidable content 200 is schematically shown to help understand the technical solution. In the focus centering method of this embodiment, the number, size, and layout of the slidable content 200 are not limited. Figure 2 Limitation of the displayed slidable content 200. In actual application scenarios, the number, shape, size, layout, etc. of the slidable content 200 are determined according to actual needs.
[0044] In this embodiment, the shape of the slidable content 200 is a rectangle.
[0045] Since the shape of the slidable content 200 is a rectangle, the shape of the slidable content 200 is a regular shape, which is beneficial to reducing the difficulty and amount of data calculation when obtaining the first specified value, the second specified value, the third specified value and the first sliding value in steps S200 to S400 to be described later, thereby reducing the calculation load of the electronic device when implementing the focus centering method, allowing the electronic device to run smoothly. At the same time, the code readability of the method for implementing the focus centering is improved, and the development difficulty is reduced.
[0046] It should be understood that even if the slidable content displayed in the electronic device is not rectangular but circular, polygonal or other irregular shapes, the slidable content 200 can still be formed by centering or approximately centering the slidable content (non-rectangular) in a preset rectangular area. At this time, all parts in the rectangular area constitute the rectangular slidable content 200.
[0047] In some other embodiments, the shape of the slidable content 200 is a circle, a polygon or other irregular shapes. Thus, the slidable content displayed in the electronic device is diversified and the user experience is good.
[0048] In this embodiment, the number of the slidable contents 200 is more than 2, and among the slidable contents, the sizes of at least 2 of the slidable contents are different. Thus, the slidable contents displayed in the electronic device are diversified and the user experience is good.
[0049] The parent control is a slidable control, and the electronic device displays the content in the display area 110. For example, the electronic device displays the slidable content 200 located in the display area 110.
[0050] The parent control in this embodiment can slide to display a variety of slidable content, that is, the size, shape, and layout of the plurality of slidable contents 200 in the parent control are less restricted, and the electronic device can display slidable content 200 in various layouts, sizes, and shapes, so that the user experience is good.
[0051] Specifically, the parent control includes RecyclerView, ListView or ScrollView.
[0052] In this embodiment, the first designated boundary 101 is parallel or perpendicular to the sliding direction of the plurality of slidable contents 200 (eg Figure 2 ), the third designated boundary 102 is perpendicular to the first designated boundary 101.
[0053] Specifically, the parent control includes an upper boundary of the parent control, a lower boundary of the parent control, a left boundary of the parent control, and a right boundary of the parent control. The first designated boundary 101 is the upper boundary of the parent control, and the third designated boundary 102 is the left boundary of the parent control.
[0054] In this embodiment, the display area 110 includes a second designated boundary 111 and a fourth designated boundary 112 . The second designated boundary 111 is parallel to and adjacent to the first designated boundary 101 , and the fourth designated boundary 112 is parallel to and adjacent to the third designated boundary 102 .
[0055] Specifically, the display area 110 includes an upper boundary of the display area 110, a lower boundary of the display area 110, a left boundary of the display area 110, and a right boundary of the display area 110. The second designated boundary 111 is the upper boundary of the display area 110, and the fourth designated boundary 112 is the left boundary of the display area 110.
[0056] In some other embodiments, the first specified border is the bottom border of the parent control, the second specified border is the bottom border of the display area, the third specified border is the left border of the parent control, and the fourth specified border is the left border of the display area.
[0057] In some other embodiments, the first specified boundary is the left boundary of the parent control, the second specified boundary is the left boundary of the display area, the third specified boundary is the upper boundary of the parent control or the lower boundary of the parent control, and the fourth specified boundary is the upper boundary or the lower boundary of the display area.
[0058] In another embodiment, the parent control does not include the third specified boundary, the display area does not include the fourth specified boundary, and the method for centering the focus does not perform steps S500 to S700 described later. Thus, the current focus is horizontally or vertically centered in the display area, that is, the current focus implements a centering strategy in one direction.
[0059] It should be noted that after the plurality of slidable contents 200 are added to the parent control, the layout of the plurality of slidable contents 200 in the parent control is fixed, and the positional relationship between the plurality of slidable contents 200 and the upper boundary of the parent control, the lower boundary of the parent control, the left boundary of the parent control, and the right boundary of the parent control is also fixed. Therefore, the sliding of the slidable contents 200 is achieved by sliding the plurality of slidable contents 200 added to the parent control up and down and left and right as a whole.
[0060] At the same time, the upper boundary, the lower boundary, the left boundary and the right boundary of the parent control slide together with the plurality of slidable contents 200 , while the position of the display area 110 remains fixed.
[0061] In addition, in step S100, the plurality of slidable contents 200 added to the parent control need to include at least the original focus and the current focus to execute steps S200 to S400. Accordingly, the slidable contents 200 that are not the original focus and the current focus can be added to the parent control multiple times and at any time. In other words, the slidable contents 200 added to the parent control can be increased or decreased, but when a slidable content 200 is added to the parent control, the layout in the parent control is fixed.
[0062] Please refer to Figure 1 and Figure 3 , Figure 3It is a schematic diagram of the original focus and the current focus in an embodiment of the present invention. Step S200 is executed. When it is monitored that the focus changes from the original focus to the current focus in a number of slidable contents 200, the first specified value X1 of the current focus, the second specified value X2 of the current focus, the first specified value Y1 of the original focus, and the third specified value Y3 of the original focus are called back.
[0063] It should be noted that, for ease of understanding, Figure 3 Only the original focus and the current focus of some slidable contents 200 are shown, and the slidable contents 200 other than the original focus and the current focus are not shown. Figure 3 Displayed in.
[0064] In this embodiment, the Android ViewTreeObserver class is used to monitor the focus changes of several slidable contents. The Android ViewTreeObserver class is a native monitoring class of the Android system. Therefore, in this embodiment, the monitoring of the changes of the original focus and the current focus, as well as the callback of the first specified value X1 of the current focus, the second specified value X2 of the current focus, the first specified value Y1 of the original focus, and the third specified value Y3 of the original focus are realized based on the native monitoring class of the Android system.
[0065] In this embodiment, the first specified value is the minimum distance (getTop value) between the edge of the slidable content 200 and the first specified boundary 101 .
[0066] Correspondingly, the first designated value X1 of the current focus is the minimum distance between the edge of the current focus and the first designated boundary 101 , and the first designated value Y1 of the original focus is the minimum distance between the edge of the original focus and the first designated boundary 101 .
[0067] In some other embodiments, when the first specified boundary is the lower boundary of the parent control, the first specified value is the minimum distance between the edge of the slidable content and the lower boundary of the parent control. Correspondingly, the first specified value X1 of the current focus is the minimum distance between the edge of the current focus and the lower boundary of the parent control, and the first specified value Y1 of the original focus is the minimum distance between the edge of the original focus and the lower boundary of the parent control.
[0068] In some other embodiments, when the first designated boundary is the left boundary of the parent control, the first designated value is the minimum distance between the edge of the slidable content and the left boundary of the parent control. Correspondingly, the first designated value X1 of the current focus is the minimum distance between the edge of the current focus and the left boundary of the parent control, and the first designated value Y1 of the original focus is the minimum distance between the edge of the original focus and the left boundary of the parent control.
[0069] In this embodiment, the second specified value is the maximum distance (gettBottom value) between the edge of the slidable content 200 and the first specified boundary 101 .
[0070] Correspondingly, the second designated value X2 of the current focus is the maximum distance between the edge of the current focus and the first designated boundary 101 .
[0071] In some other embodiments, when the first specified boundary is the lower boundary of the parent control, the second specified value is the maximum distance between the edge of the slidable content and the lower boundary of the parent control. Correspondingly, the second specified value X2 of the current focus is the maximum distance between the edge of the current focus and the lower boundary of the parent control.
[0072] In some other embodiments, when the first specified boundary is the left boundary of the parent control, the second specified value is the maximum distance between the edge of the slidable content and the left boundary of the parent control. Correspondingly, the second specified value X2 of the current focus is the maximum distance between the edge of the current focus and the left boundary of the parent control.
[0073] In this embodiment, the third specified value is the minimum distance between the edge of the slidable content 200 and the second specified boundary 111. Accordingly, the third specified value Y3 of the original focus is the minimum distance between the edge of the original focus and the second specified boundary 111.
[0074] In some other embodiments, when the second specified boundary is the lower boundary of the display area, the third specified value is the minimum distance between the edge of the slidable content and the lower boundary of the display area. Correspondingly, the third specified value Y3 of the original focus is the minimum distance between the edge of the original focus and the lower boundary of the display area.
[0075] In some other embodiments, when the second designated boundary is the left boundary of the display area, the third designated value is the minimum distance between the edge of the slidable content and the left boundary of the display area. Correspondingly, the third designated value Y3 of the original focus is the minimum distance between the edge of the original focus and the left boundary of the display area.
[0076] Please continue to refer to Figure 1 and Figure 3 , execute step S300, and obtain the first sliding value A according to the first specified value X1 of the current focus, the second specified value X2 of the current focus, the first specified value Y1 of the original focus, the third specified value Y3 of the original focus, and the size F1 of the display area 110 in the direction perpendicular to the first specified boundary 101.
[0077] The size F1 of the display area 110 in a direction perpendicular to the first designated boundary 101 is a fixed parameter of the electronic device.
[0078] It should be understood that, since the size F1 is a fixed parameter (static parameter) of the electronic device, it does not need to be obtained through the native monitoring class of the Android system, and can be directly obtained from the Android system of the electronic device.
[0079] In this embodiment, the size F1 is the height of the display area 110 , and the first sliding value A is used to slide the current focus position to the vertical center of the display area 110 to achieve vertical centering of the focus.
[0080] In some other embodiments, when the first specified boundary is the lower boundary of the parent control, the size of the display area in a direction perpendicular to the first specified boundary is the height of the display area, and the first sliding value A is used to slide the position of the current focus to the vertical center of the display area to achieve vertical centering of the focus.
[0081] In some other embodiments, when the first specified boundary is the left boundary of the parent control, the size of the display area in a direction perpendicular to the first specified boundary is the width of the display area, and the first sliding value A is used to slide the current focus position to the horizontal center of the display area to achieve horizontal centering of the focus.
[0082] Please refer to Figures 4 to 6 , Figure 4 is a flow chart of a method for obtaining a first sliding value in one embodiment of the present invention, Figure 5 is a schematic diagram of the relationship between the first sliding value and the first position of the current focus in one embodiment of the present invention, Figure 6 is a schematic diagram of the relationship between the first sliding value and the second position of the current focus in one embodiment of the present invention. For step S300, the method for obtaining the first sliding value A according to the first designated value X1 of the current focus, the second designated value X2 of the current focus, the first designated value Y1 of the original focus, the third designated value Y3 of the original focus, and the size F1 of the display area 110 in the direction perpendicular to the first designated boundary 101 further includes:
[0083] Step S310, obtaining the distance K between the center of the current focus and the first specified boundary according to the first specified value X1 of the current focus and the second specified value X2 of the current focus, wherein,
[0084] Step S320, obtaining a distance M between the first designated boundary and the second designated boundary according to the first designated value Y1 of the original focus and the third designated value Y3 of the original focus, wherein M=Y1-Y3;
[0085] Step S330, obtaining a first sliding value A according to the spacing K, the spacing M, and the size F1 of the display area in a direction perpendicular to the first specified boundary, wherein:
[0086] In this embodiment, the distance K is the distance between the center of the current focus and the first designated boundary 101 , and the distance M is the distance between the first designated boundary 101 and the second designated boundary 111 .
[0087] In some other embodiments, when the first specified boundary is the bottom boundary of the parent control and the second specified boundary is the bottom boundary of the display area, the spacing K is the spacing between the center of the current focus and the bottom boundary of the parent control, and the spacing M is the spacing between the bottom boundary of the parent control and the bottom boundary of the display area.
[0088] In some other embodiments, when the first specified boundary is the left boundary of the parent control and the second specified boundary is the left boundary of the display area, the spacing K is the spacing between the center of the current focus and the left boundary of the parent control, and the spacing M is the spacing between the left boundary of the parent control and the left boundary of the display area.
[0089] In this embodiment, the absolute value of the first sliding value A is the distance between the center line 115 of the display area 110 along the height direction and the center of the current focus.
[0090] In this embodiment, by locating the center of the current focus on the center line 115, the current focus can be centered in the display area 110 in a direction perpendicular to the first designated boundary 101, thereby realizing a focus centering strategy for the current focus in a direction perpendicular to the first designated boundary 101.
[0091] It should be noted that Figure 5 Schematically shows the positional relationship between the center of the current focus and the center line 115 when the first sliding value A>0. Figure 6 Schematically shows the positional relationship between the center of the current focus and the center line 115 when the first sliding value A is less than 0.
[0092] from Figure 5 It can be seen that when the first sliding value A>0, in order to realize the centering of the current focus in the direction perpendicular to the first designated boundary 101, the current focus needs to be moved toward the first designated boundary 101 in the direction perpendicular to the first designated boundary 101.
[0093] from Figure 6 It can be seen that when the first sliding value A is less than 0, in order to realize the centering of the current focus in the direction perpendicular to the first designated boundary 101 , the current focus needs to be moved in the direction perpendicular to the first designated boundary 101 and away from the first designated boundary 101 .
[0094] Please continue to refer to Figure 1 , execute step S400, when it is monitored that the focus changes from the original focus to the current focus in the plurality of slidable contents 200, the parent control slides the plurality of slidable contents 200 in a direction perpendicular to the first designated boundary 101 according to the first sliding value A.
[0095] The parent control slides the plurality of slidable contents 200 in a direction perpendicular to the first designated boundary 101 according to the first sliding value A, which specifically means that the plurality of slidable contents 200 added to the parent control slide as a whole according to the first sliding value A. At the same time, the upper boundary (first designated boundary 101) of the parent control slides accordingly. Please refer to the description in step S100 for the sliding method of the slidable contents 200, which will not be repeated here.
[0096] Specifically, when the parent control slides the plurality of slidable contents 200 in a direction perpendicular to the first designated boundary 101 according to the first sliding value A, the current focus is vertically centered in the display area 110 .
[0097] In some other embodiments, when the first designated boundary is the left boundary of the parent control, when a number of slidable contents are slid in a direction perpendicular to the first designated boundary, horizontal centering of the current focus in the display area is achieved.
[0098] Because in the focus centering method, when it is monitored that the focus changes from the original focus to the current focus in several slidable contents, the first specified value of the current focus, the second specified value of the current focus, the first specified value of the original focus and the third specified value of the original focus are called back to obtain the first sliding value, and the parent control slides the several slidable contents according to the first sliding value. Therefore, while at least horizontal centering or vertical centering of the current focus is achieved, a parent control that is compatible with a variety of display contents (slidable contents) can also be used. Therefore, through the focus centering method, electronic devices using the Android system can take into account both focus centering (at least horizontal centering or vertical centering) and diversification of display contents, thereby improving the user experience.
[0099] Specifically, in the focus centering method, through the native monitoring class of the Android system, on the one hand, it is possible to monitor the focus changes of several slidable contents, and on the other hand, it is possible to implement the callback of the first specified value, the second specified value, and the third specified value of any slidable content to obtain the first sliding value. Therefore, through simple calculations and a small amount of data interaction, the current focus centering strategy can be implemented when the focus changes. On this basis, the focus centering method can be used as a centering strategy for any slidable control, so that the type of parent control of the slidable control is less restricted. Therefore, the existing parent control that is compatible with a variety of display content can be used. Therefore, the focus centering method can enable electronic devices using the Android system to take into account both the focus centering and the diversification of the display content.
[0100] Moreover, since the focus centering method can realize the current focus centering strategy through the native monitoring class of the Android system and the existing parent control that is compatible with a variety of display contents, the focus centering method is easy to implement and promote.
[0101] Please refer to Figures 7 to 9 , Figure 7 is a flowchart of a method for sliding a plurality of slidable contents according to a first sliding value in one embodiment of the present invention, Figure 8 is a schematic diagram of a first sliding of the focus in a direction perpendicular to the first designated boundary in one embodiment of the present invention, Fig. 9 1 is a schematic diagram of a second sliding of the current focus in a direction perpendicular to the first specified boundary in an embodiment of the present invention. For step S400, when it is monitored that the focus changes from the original focus to the current focus in the plurality of slidable contents 200, the method for the parent control to slide the plurality of slidable contents 200 in a direction perpendicular to the first specified boundary 101 according to the first sliding value A further includes:
[0102] Step S410: when the first sliding value A>0, the plurality of slidable contents slide the first sliding value A toward the first designated boundary;
[0103] Step S420: when the first sliding value A is less than 0, the plurality of slidable contents slide away from the first designated boundary by the absolute value of the first sliding value A;
[0104] Step S430: when the first sliding value A=0, the plurality of slidable contents do not slide in a direction perpendicular to the first designated boundary.
[0105] Specifically, for step S410 , when the first sliding value A>0, the plurality of slidable contents 200 and the first designated boundary 101 slide from the original position S1 toward the first designated boundary 101 by a distance of the first sliding value A.
[0106] Regarding step S420 , when the first sliding value A<0, the plurality of slidable contents 200 and the first designated boundary 101 slide from the original position S1 to the first designated boundary 101 by a distance equal to the absolute value of the first sliding value A.
[0107] In this embodiment, when the first sliding value A=0, since the current focus is vertically centered in the display area 110 in the direction perpendicular to the first designated boundary, some slidable contents 200 and the first designated boundary 101 do not slide in the direction perpendicular to the first designated boundary 101.
[0108] In some other embodiments, the first designated boundary is the left boundary of the parent control. When the first sliding value A=0, since the current focus is horizontally centered in the display area in the direction perpendicular to the first designated boundary, the plurality of slidable contents and the first designated boundary do not slide in the direction perpendicular to the first designated boundary.
[0109] It should be noted that, for ease of understanding, Figure 8 and Fig. 9 Only the original focus and the current focus of some slidable contents 200 are shown, and the slidable contents 200 other than the original focus and the current focus are not shown. Figure 8 and Fig. 9 Displayed in.
[0110] Specifically, Figure 8 Schematically shows the position changes of the original focus, the current focus, and the first designated boundary 101 in the direction perpendicular to the first designated boundary 101 when the first sliding value A>0. Fig. 9 Schematically shows the position changes of the original focus, the current focus, and the first designated boundary 101 in the direction perpendicular to the first designated boundary 101 when the first sliding value A is less than 0.
[0111] In this embodiment, the Android ViewTreeObserver class is used to monitor the focus changes of several slidable contents. The Android ViewTreeObserver class is a native monitoring class of the Android system. Therefore, in this embodiment, the monitoring of the changes of the original focus and the current focus, as well as the callback of the first specified value X1 of the current focus, the second specified value X2 of the current focus, the first specified value Y1 of the original focus, and the third specified value Y3 of the original focus are realized based on the native monitoring class of the Android system.
[0112] Please continue to refer to Figure 1 and Figure 3 , execute step S500, and when it is monitored that the focus changes from the original focus to the current focus in the plurality of slidable contents 200, call back the fourth specified value X4 of the current focus, the fifth specified value X5 of the current focus, the fourth specified value Y4 of the original focus, and the sixth specified value Y6 of the original focus.
[0113] In this embodiment, the fourth designated value X4 of the current focus, the fifth designated value X5 of the current focus, the fourth designated value Y4 of the original focus, and the sixth designated value Y6 of the original focus are called back through the native monitoring class of the Android system.
[0114] In this embodiment, the fourth specified value is the minimum distance (getLeft value) between the edge of the slidable content 200 and the third specified boundary 102 .
[0115] Correspondingly, the fourth designated value X4 of the current focus is the minimum distance between the edge of the current focus and the third designated boundary 102 , and the fourth designated value Y4 of the original focus is the minimum distance between the edge of the original focus and the third designated boundary 102 .
[0116] In some other embodiments, when the third specified boundary is the upper boundary of the parent control, the fourth specified value is the minimum distance between the edge of the slidable content and the upper boundary of the parent control. Correspondingly, the fourth specified value X4 of the current focus is the minimum distance between the edge of the current focus and the upper boundary of the parent control, and the fourth specified value Y4 of the original focus is the minimum distance between the edge of the original focus and the upper boundary of the parent control.
[0117] In some other embodiments, when the third specified boundary is the lower boundary of the parent control, the fourth specified value is the minimum distance between the edge of the slidable content and the lower boundary of the parent control. Correspondingly, the fourth specified value X4 of the current focus is the minimum distance between the edge of the current focus and the lower boundary of the parent control, and the fourth specified value Y4 of the original focus is the minimum distance between the edge of the original focus and the lower boundary of the parent control.
[0118] In this embodiment, the fifth specified value is the maximum distance (getRight value) between the edge of the slidable content 200 and the third specified boundary 102 .
[0119] Correspondingly, the fifth designated value X5 of the current focus is the maximum distance between the edge of the current focus and the third designated boundary 102 .
[0120] In some other embodiments, when the third specified boundary is the upper boundary of the parent control, the fifth specified value is the maximum distance between the edge of the slidable content and the upper boundary of the parent control. Correspondingly, the fifth specified value X5 of the current focus is the maximum distance between the edge of the current focus and the upper boundary of the parent control.
[0121] In some other embodiments, when the third specified boundary is the lower boundary of the parent control, the fifth specified value is the maximum distance between the edge of the slidable content and the lower boundary of the parent control. Correspondingly, the fifth specified value X5 of the current focus is the maximum distance between the edge of the current focus and the lower boundary of the parent control.
[0122] In this embodiment, the sixth designated value is the minimum distance between the edge of the slidable content 200 and the fourth designated boundary 112 .
[0123] Correspondingly, the sixth designated value Y6 of the original focus is the minimum distance between the edge of the original focus and the fourth designated boundary 112 .
[0124] In some other embodiments, when the fourth designated boundary is the upper boundary of the display area, the sixth designated value is the minimum distance between the edge of the slidable content and the upper boundary of the display area. Correspondingly, the sixth designated value Y6 of the original focus is the minimum distance between the edge of the original focus and the upper boundary of the display area.
[0125] In some other embodiments, when the fourth designated boundary is the lower boundary of the display area, the sixth designated value is the minimum distance between the edge of the slidable content and the lower boundary of the display area. Correspondingly, the sixth designated value Y6 of the original focus is the minimum distance between the edge of the original focus and the lower boundary of the display area.
[0126] Please continue to refer to Figure 1 and Figure 3 , execute step S600, and obtain the second sliding value B according to the fourth specified value X4 of the current focus, the fifth specified value X5 of the current focus, the fourth specified value Y4 of the original focus, the sixth specified value Y6 of the original focus, and the size F2 of the display area 110 in the direction parallel to the first specified boundary 101.
[0127] The size F2 of the display area 110 in the direction parallel to the first designated boundary 101 is a fixed parameter of the electronic device.
[0128] It should be understood that, since the size F2 is a fixed parameter (static parameter) of the electronic device, it does not need to be obtained through the native monitoring class of the Android system, and can be directly obtained from the Android system of the electronic device.
[0129] In this embodiment, the size F2 is the width of the display area 110 , and the second sliding value B is used to slide the current focus position to the horizontal center of the display area 110 to achieve horizontal centering of the focus.
[0130] In some other embodiments, when the first specified boundary is the lower boundary of the parent control, the size of the display area in a direction parallel to the first specified boundary is the width of the display area, and the second sliding value B is used to slide the position of the current focus to the horizontal center of the display area to achieve horizontal centering of the focus.
[0131] In some other embodiments, when the first specified boundary is the left boundary of the parent control, the size of the display area in a direction parallel to the first specified boundary is the height of the display area, and the second sliding value B is used to slide the position of the current focus to the vertical center of the display area to achieve vertical centering of the focus.
[0132] Please refer to Figures 10 to 12 , Fig.10 is a flow chart of a method for obtaining a second sliding value in one embodiment of the present invention, Fig.11 is a schematic diagram of the relationship between the second sliding value and the first position of the current focus in one embodiment of the present invention, Fig.12is a schematic diagram of the first position relationship between the second sliding value and the current focus in an embodiment of the present invention. For step S600, the method for obtaining the second sliding value B according to the fourth designated value X4 of the current focus, the fifth designated value X5 of the current focus, the fourth designated value Y4 of the original focus, the sixth designated value Y6 of the original focus, and the size F2 of the display area 110 in the direction parallel to the first designated boundary 101 further includes:
[0133] Step S610, obtaining the distance T between the center of the current focus and the third specified boundary according to the fourth specified value X4 of the current focus and the fifth specified value X5 of the current focus, wherein:
[0134] Step S620, obtaining a distance R between the third designated boundary and the fourth designated boundary according to the fourth designated value Y4 of the original focus and the sixth designated value Y6 of the original focus, wherein R=Y4-Y6;
[0135] Step S630, obtaining a second sliding value B according to the spacing T, the spacing R, and the size F2 of the display area in a direction parallel to the first specified boundary, wherein:
[0136] In this embodiment, the distance T is the distance between the center of the current focus and the third designated boundary 102 , and the distance R is the distance between the third designated boundary 102 and the fourth designated boundary 112 .
[0137] In some other embodiments, when the third specified boundary is the upper boundary of the parent control and the fourth specified boundary is the upper boundary of the display area, the spacing T is the spacing between the center of the current focus and the upper boundary of the parent control, and the spacing R is the spacing between the upper boundary of the parent control and the upper boundary of the display area.
[0138] In some other embodiments, when the third specified boundary is the bottom boundary of the parent control and the fourth specified boundary is the bottom boundary of the display area, the spacing T is the spacing between the center of the current focus and the bottom boundary of the parent control, and the spacing R is the spacing between the bottom boundary of the parent control and the bottom boundary of the display area.
[0139] In this embodiment, the absolute value of the second sliding value B is the distance between the center line 116 of the display area 110 along the width direction and the center of the current focus.
[0140] In this embodiment, by locating the center of the current focus on the center line 116, the current focus can be centered in the display area 110 in a direction parallel to the first designated boundary 101, thereby realizing a focus centering strategy for the current focus in a direction parallel to the first designated boundary 101.
[0141] It should be noted that Fig.11Schematically shows: when the second sliding value B>0, the positional relationship between the center of the current focus and the center line 116. Fig.12 Schematically shows: when the second sliding value B is less than 0, the positional relationship between the center of the current focus and the center line 116.
[0142] from Fig.11 It can be seen that when the second sliding value B>0, in order to realize the centering of the current focus in the direction parallel to the first designated boundary 101, the current focus needs to be moved in the direction parallel to the first designated boundary 101 toward the third designated boundary 102.
[0143] from Fig.12 It can be seen that when the second sliding value B is less than 0, in order to realize the centering of the current focus in the direction parallel to the first designated boundary 101 , the current focus needs to be moved in the direction parallel to the first designated boundary 101 and away from the third designated boundary 102 .
[0144] Please continue to refer to Figure 1 , execute step S700, when it is monitored that the focus changes from the original focus to the current focus in the plurality of slidable contents 200, the parent control slides the plurality of slidable contents 200 in a direction parallel to the first designated boundary 101 according to the second sliding value B.
[0145] In this embodiment, the plurality of slidable contents 200 added to the parent control not only slide as a whole according to the first sliding value A, but also slide as a whole according to the second sliding value B. At the same time, not only the upper boundary (first designated boundary 101) of the parent control slides accordingly, but also the left boundary (third designated boundary 102) of the parent control slides accordingly. Please refer to the description in step S100 for the sliding method of the slidable contents 200, which will not be repeated here.
[0146] Specifically, when the parent control slides the plurality of slidable contents 200 in a direction parallel to the first designated boundary 101 according to the second sliding value B, the current focus is horizontally centered in the display area 110 .
[0147] In this embodiment, in the focus centering method, when it is monitored that the focus changes from the original focus to the current focus in several slidable contents, the fourth specified value of the current focus, the fifth specified value of the current focus, the fourth specified value of the original focus, and the sixth specified value of the original focus are called back to obtain the second sliding value, and the parent control also slides the several slidable contents according to the second sliding value. Therefore, the focus centering method can be easily implemented, promoted, and compatible with parent controls of various display contents (slidable contents), while also taking into account the horizontal centering strategy and the vertical centering strategy, so that the current focus can be displayed in the center of the display area. Therefore, when users use electronic devices, the display of the current focus is easier for users to see, further improving the user experience.
[0148] In another embodiment, steps S500 to S700 are not performed. Thus, compared with performing steps S500 to S700, the amount of data calculation performed by the electronic device to implement the focus centering strategy is reduced, the code complexity of the method for implementing the focus centering is simplified, and the development difficulty is reduced.
[0149] Please refer to Figures 13 to 15 , Fig.13 is a flowchart of a method for sliding a plurality of slidable contents according to a second sliding value in one embodiment of the present invention, Fig.14 is a first sliding schematic diagram of a focus in a direction parallel to a first designated boundary in an embodiment of the present invention, Fig.15 1 is a schematic diagram of a second sliding of the current focus in a direction parallel to the first specified boundary in an embodiment of the present invention. For step S700, when it is monitored that the focus changes from the original focus to the current focus in the plurality of slidable contents 200, the method for the parent control to slide the plurality of slidable contents 200 in a direction parallel to the first specified boundary 101 according to the second sliding value B further includes:
[0150] Step S710, when the second sliding value B>0, the plurality of slidable contents slide the sliding value B toward the third specified boundary;
[0151] Step S720, when the second sliding value B is less than 0, the plurality of slidable contents slide away from the third specified boundary by the absolute value of the sliding value B;
[0152] Step S730: when the second sliding value B=0, the plurality of slidable contents do not slide in a direction parallel to the first designated boundary.
[0153] Specifically, for step S710 , when the second sliding value B>0, the plurality of slidable contents 200 and the third designated boundary 102 slide from the original position S2 toward the third designated boundary 102 by a distance of the second sliding value B.
[0154] Regarding step S720 , when the second sliding value B<0, the plurality of slidable contents 200 and the third designated boundary 102 slide from the original position S2 to the third designated boundary 102 by a distance equal to the absolute value of the second sliding value B.
[0155] In this embodiment, when the second sliding value B=0, since the current focus is horizontally centered in the display area 110 in the direction parallel to the first designated boundary, some slidable contents 200 and the third designated boundary 102 do not slide in the direction parallel to the third designated boundary 102.
[0156] It should be noted that, for ease of understanding, Fig.14 and Fig.15 Only the original focus and the current focus of some slidable contents 200 are shown, and the slidable contents 200 other than the original focus and the current focus are not shown. Fig.14 and Fig.15 Displayed in.
[0157] also, Figure 8 , Fig. 9 , Fig.14 and Fig.15 Although the sliding modes of the plurality of slidable contents 200 in one direction are schematically shown respectively, in the present embodiment, the plurality of slidable contents 200 actually slide in two directions (a direction perpendicular to the first designated boundary 101 and a direction parallel to the first designated boundary 101) at the same time to realize a focus centering strategy in which the current focus is at the exact center of the display area 110.
[0158] Specifically, Fig.14 It is schematically shown in FIG. 1 that when the second sliding value B>0, the positions of the original focus, the current focus, and the third designated boundary 102 in the direction parallel to the third designated boundary 102 change. Fig.15 It is schematically shown in FIG. 1 that when the second sliding value B is less than 0, the positions of the original focus, the current focus, and the third designated boundary 102 change in a direction parallel to the first designated boundary 101 .
[0159] In this embodiment, the native monitoring class of the Android system is used to implement callbacks of the fourth designated value X4 of the current focus, the fifth designated value X5 of the current focus, the fourth designated value Y4 of the original focus, and the sixth designated value Y6 of the original focus.
[0160] Correspondingly, an embodiment of the present invention further provides a storage medium on which computer instructions are stored, wherein when the computer instructions are executed by a processor, the focus centering method described above is implemented.
[0161] Correspondingly, an embodiment of the present invention also provides an electronic device, including a processor, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to implement instructions for the steps in the above-mentioned focus centering method when executed by the processor.
[0162] Specifically, the electronic device includes a smart TV.
[0163] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.
Claims
1. A method for centering focus, characterized in that: include: A parent control, the parent control comprising a first designated boundary and a display area, the first designated boundary being parallel or perpendicular to a sliding direction of the plurality of slidable contents, the display area comprising a second designated boundary, the second designated boundary being parallel to and adjacent to the first designated boundary; When monitoring that the focus changes from the original focus to the current focus in some slidable contents, the first specified value of the current focus, the second specified value of the current focus, the first specified value of the original focus, and the third specified value of the original focus are called back; According to the first specified value X1 of the current focus and the second specified value X2 of the current focus, the distance K between the center of the current focus and the first specified boundary is obtained, wherein: According to the first specified value Y1 of the original focus and the third specified value Y3 of the original focus, the spacing M between the first specified boundary and the second specified boundary is obtained, where M=Y1-Y3; according to the spacing K, the spacing M, and the size F1 of the display area in the direction perpendicular to the first specified boundary, the first sliding value A is obtained, where The parent control slides the plurality of slidable contents in a direction perpendicular to the first designated boundary according to the first sliding value; Among them, the first specified value is the minimum distance between the edge of the slidable content and the first specified boundary, the second specified value is the maximum distance between the edge of the slidable content and the first specified boundary, and the third specified value is the minimum distance between the edge of the slidable content and the second specified boundary.
2. The method for centering focus according to claim 1, wherein when it is monitored that the focus changes from the original focus to the current focus in a plurality of slidable contents, the method for the parent control to slide the plurality of slidable contents in a direction perpendicular to the first specified boundary according to the first sliding value comprises: When the first sliding value A>0, the plurality of slidable contents slide the sliding value A toward the first designated boundary; When the first sliding value A is less than 0, the plurality of slidable contents slide away from the first designated boundary by the absolute value of the sliding value A; When the first sliding value A=0, the plurality of slidable contents do not slide in a direction perpendicular to the first designated boundary.
3. The method for centering focus according to any one of claims 1 or 2, wherein the parent control further comprises a third specified boundary, the third specified boundary is perpendicular to the first specified boundary, the display area further comprises a fourth specified boundary, the fourth specified boundary is parallel to and adjacent to the third specified boundary, and the method for centering focus further comprises: When it is monitored that the focus changes from the original focus to the current focus in several slidable contents, the fourth specified value of the current focus, the fifth specified value of the current focus, the fourth specified value of the original focus, and the sixth specified value of the original focus are called back, wherein the fourth specified value is the minimum distance between the edge of the slidable content and the third specified boundary, the fifth specified value is the maximum distance between the edge of the slidable content and the third specified boundary, and the sixth specified value is the minimum distance between the edge of the slidable content and the fourth specified boundary; Obtaining a second sliding value according to a fourth specified value of the current focus, a fifth specified value of the current focus, a fourth specified value of the original focus, a sixth specified value of the original focus, and a size of the display area in a direction parallel to the first specified boundary; When it is monitored that the focus changes from the original focus to the current focus in the plurality of slidable contents, the parent control slides the plurality of slidable contents in a direction parallel to the first designated boundary according to the second sliding value.
4. The method for centering focus according to claim 3, wherein the method for obtaining the second sliding value according to the fourth specified value of the current focus, the fifth specified value of the current focus, the fourth specified value of the original focus, the sixth specified value of the original focus, and the size of the display area in a direction parallel to the first specified boundary comprises: According to the fourth specified value X4 of the current focus and the fifth specified value X5 of the current focus, the distance T between the center of the current focus and the third specified boundary is obtained, wherein, According to the fourth designated value Y4 of the original focus and the sixth designated value Y6 of the original focus, obtaining a distance R between the third designated boundary and the fourth designated boundary, wherein R=Y4-Y6; The second sliding value B is obtained according to the spacing T, the spacing R, and the size F2 of the display area in a direction parallel to the first specified boundary, wherein:
5. The method for centering focus according to claim 4, wherein when monitoring that the focus changes from the original focus to the current focus in a plurality of slidable contents, the method for the parent control to slide the plurality of slidable contents in a direction parallel to the first specified boundary according to the second sliding value comprises: When the second sliding value B>0, the plurality of slidable contents slide the sliding value B toward the third specified boundary; When the second sliding value B is less than 0, the plurality of slidable contents slide away from the third specified boundary by the absolute value of the sliding value B; When the second sliding value B=0, the plurality of slidable contents do not slide in a direction parallel to the first designated boundary.
6. The focus centering method as described in claim 1, when the number of the plurality of slidable contents is more than 2, among the plurality of slidable contents, the sizes of at least 2 of the plurality of slidable contents are different.
7. The focus centering method as described in claim 1, wherein the shape of the slidable content is any one of a rectangle, a circle or a polygon.
8. The focus centering method as described in claim 1, wherein the parent control includes RecyclerView, ListView or ScrollView.
9. The method for centering focus as described in claim 1, using the Android ViewTreeObserver class to monitor the focus changes of the plurality of slidable contents.
10. A storage medium having computer instructions stored thereon, characterized in that: When the computer instructions are executed by a processor, the focus centering method according to any one of claims 1 to 9 is implemented.
11. An electronic device, characterized in that: The invention comprises a processor, a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to implement the instructions of the steps in the focus centering method according to any one of claims 1 to 9 when executed by the processor.
