Foreword:
Instead of catching fish in troubled waters every day, it's better to learn more and improve your competitiveness.
Android intermediate and advanced knowledge points:
1. Performance optimization
1. APP stability optimization
1. What stability optimizations have you made?
2. How does performance stability do?
3. How to ensure business stability?
4. If there is an abnormality, how to stop the loss quickly?
2. Optimized APP startup speed
1. What is the principle of startup optimization?
2. How is it asynchronous? Have you encountered any problems with asynchrony?
3. What are the easily overlooked aspects of startup optimization?
4. Is there a good solution to the slow startup caused by version iteration?
1. The view rendering mechanism is divided into:
- onLaout and onMeasure
- onDraw mapping mechanism
2. Common views include:
1.RecycleView
- Interpret the source code
- LayoutManager LayoutManager
- Item Decoration ItemDecoration
- ViewHolder and recycling reuse mechanism
2.CardView
- Source code solution
- The realization principle of rounded shadow
- Adaptation of shadows and margins below 5.0
3.viewpager
- Loading mechanism and how to optimize
- How to combine with Fragment
4.Webview
- Principle analysis
- JS and java interaction
- Multi-threaded WebView use
- WebView and native communication framework
Three. Layout ViewGroup
- ConstaintLayout
- LinearLayout
- RelativeLayout
- FrameLayout
- GridLayout
Four. View drawing process
4.1 Custom controls:
1. Combination controls . This kind of custom control does not need to be drawn by ourselves, but a new control composed of native controls. Such as the title bar.
2. Inherit the original controls . In addition to the methods provided by the native control, this custom control can add some methods by yourself. Such as making rounded corners, round pictures.
3. Fully custom control : All the content displayed on this View is drawn by ourselves. For example, make a water ripple progress bar.
View drawing process:OnMeasure()——>OnLayout()——>OnDraw()
- Step 1
OnMeasure()
: Measure the size of the view. The measure method is called recursively from the top-level parent View to the child View, and the measure method calls back OnMeasure. - Step 2:
OnLayout()
Determine the View position and perform page layout. The process of recursively calling the view.layout method from the top-level parent View to the child View, that is, the parent View places the child View in a suitable position according to the layout size and layout parameters obtained by the child View in the previous step. - The third step
OnDraw()
: Draw the view.
ViewRoot creates a Canvas object and then calls OnDraw().
Six steps:
- Draw the background of the view;
- Save the layer of the canvas (Layer);
- Draw the content of View;
- Draw View subviews, if not, don’t use them;
- Restore layer (Layer);
- Draw a scroll bar.
4.2View, ViewGroup event distribution
1. There are only two protagonists in the Touch event distribution: ViewGroup and View.
ViewGroup
include onInterceptTouchEvent
, dispatchTouchEvent
, onTouchEvent
three related events.
View
contains dispatchTouchEvent
, onTouchEvent
two related events.
Among them, ViewGroup inherits from View.
2. ViewGroup and View form a tree structure, and the root node is a ViewGroup contained within the Activity.
3. Touch events are Action_Down、Action_Move、Aciton_UP
composed of, in a complete touch event, there is only one Down and Up, and there are several Moves, which can be 0.
4. When Acitivty
the Touch event is received, it will traverse the child View to distribute the Down event. ViewGroup
The traversal of can be regarded as recursive. The purpose of distribution is to find the View that really needs to handle this complete touch event, and this View will onTouchuEvent
return true in the result.
5. When a child View returns true, the distribution of the Down event will be suspended, and ViewGroup
the child View will be recorded in at the same time . The subsequent Move and Up events will be directly processed by the child View. Since the child View is stored in ViewGroup
the multi-layer ViewGroup
node structure, the upper level will ViewGroup
save the ViewGroup
object where the View that actually handles the event is located : if it returns true ViewGroup0-ViewGroup1-TextView
in the structure TextView
, it will be stored in the ViewGroup1
middle, and it ViewGroup1
will also be returned. true, is stored in ViewGroup0
. When the Move and UP events come, they will first be ViewGroup0
passed to ViewGroup1
, and then ViewGroup1
passed to TextView
.
6. When ViewGroup
the time does not capture all child View Down event will trigger ViewGroup
its own onTouch
event. The way to trigger is to call the super.dispatchTouchEvent
function, that is, the dispatchTouchEvent
method of the parent class View . In the case that all child views are not processed, the Acitivity的onTouchEvent
method is triggered .
7. onInterceptTouchEvent
There are two functions:
- Intercept the distribution of Down events.
- Suspend the Up and Move events to pass to the target View, so that the ViewGroup where the target View is located captures the Up and Move events.
How to do a good job interview surprise and plan the learning direction?
The interview question set can help you find out and fill up vacancies, have a direction and a targeted study, and prepare for future entry into a large factory. But if you just read it again, don't study and delve into it. Then this interview question will be of limited help to you. In the end, we must rely on senior technical level to speak.
There are a lot of materials for learning Android on the Internet, but if the knowledge learned is not structured, and when you encounter problems, you just taste it and don’t study it in depth, then it is difficult to achieve real technological improvement. It is recommended to formulate a learning plan first, and link the knowledge points according to the learning plan to form a systematic knowledge system.
The learning direction is easy to plan, but if you only learn through fragmented learning, it is very slow to improve yourself.
At the same time, I also collected and sorted out the 2020 Bytedance, and interview questions from companies such as Tencent, Ali, Huawei, Xiaomi, etc., and sorted out the requirements and technical points of the interview into a large and comprehensive "Android Architect" interview Xmind (in fact Expect to spend a lot of effort), including knowledge context + branch details .
When building these technical frameworks, I also organized the system's advanced advanced tutorials, which will be much better than your own fragmented learning effect.
Click: "Android Architecture Video + BAT Interview Topic PDF + Study Notes" can be obtained for free~
There are a lot of materials for learning Android on the Internet, but if the knowledge learned is not structured, and when you encounter problems, you just taste it and don’t study it in depth, then it is difficult to achieve real technological improvement. I hope this systematic technical system can provide you with a direction reference.
BF%E9%AB%98%E8%96%AA%EF%BC%81.md) can be obtained for free~
There are a lot of materials for learning Android on the Internet, but if the knowledge learned is not structured, and when you encounter problems, you just taste it and don’t study it in depth, then it is difficult to achieve real technological improvement. I hope this systematic technical system can provide you with a direction reference.