In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Android keyboard panel conflicts and layout flash processing methods, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
This time is mainly based on the practice of the core idea, the practice principle is through the CustomRootLayout layout changes, to know whether the keyboard caused the real layout changes, and then deal with the next PanelLayout onMersure.
The new algorithm no longer modifies View#LayoutParams dynamically, but in a more straightforward way.
* the code automatically dynamically adapts the panel height to the keyboard height on the original basis, which greatly optimizes the experience.
We can see that the switch from keyboard to Wechat in Wechat is seamless and unflickering, and this basic experience is in line with expectations.
But in practice, simple keyboard-to-panel switching can be flashing and problematic. Today we will analyze and solve this problem in practice.
Comparison of final results:
i. Prepare for
The following is based on android:windowSoftInputMode with adjustResize.
As shown in the figure, in order to facilitate the analysis, we divide out three View:
CustomRootView: remove statusBar and ActionBar (ToolBar … Balabala)
FootRootView: the entire bottom (the entire View including the input box and the bottom panel)
PanelView: panel View
In fact, the whole process needs to be divided into two parts:
Switch from PanelView to Keybord
Phenomenon: due to the direct PanelView#setVisibility (View.GONE) when the Keybord is displayed, the entire FooterRootView will appear to the bottom and then be pushed up by the keyboard.
Should be in line with expectations: directly by the keyboard up, do not need to go to the bottom and then up.
Switch from Keybord to PanelView
Phenomenon: because when hiding the Keybord, directly PanelView#setVisibility (View.VISIBLE), resulting in the entire FootRootView will be first on top of the keyboard, and then with the keyboard animation, down to the bottom.
As expected, it should be: as the keyboard is accepted and switched directly to the bottom, it is equipped with a flash that is lifted by the keyboard.
ii. Deal with
Principle
Adapt to Keybord only when the layout is really about to change because of PanelView. (note that all judgment processing should be completed before Super.onMeasure.)
Methods:
Through the change in the height of the CustomRootView, to ensure that the real layout will change due to the keyboard before the Super.onMeasure, and then tell the PanelView to give it a valid height before the Super.onMeasure.
It should be noted that:
1) in adjustResize mode, the height of the CustomRootView becomes smaller when the keyboard pops up, and the height of the CustomRootView becomes larger when the keyboard is retracted, and vice versa. So you can know when the real PanelView is going to change through this mechanism.
2) since the size of the onLayout,clipRect has been determined, it is necessary to avoid not calling onMeasure many times, so before the Super.onMeasure
3) because the measure will be triggered many times when the keyboard is withdrawn, if it is not determined that the layout will be changed due to the keyboard withdrawal, give it directly to View#VISIBLE, and there will still be flashes.
4) switching from Keybord to PanelView causes layout conflicts only when the Keybord is being displayed.
5) layout conflicts caused by switching from PanelView to Keybord have been handled internally in PanelView and CustomRootView.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.