Android development interview questions! Essential skills for Android architects of GitHub Markstar 1w, including iQiyi, Xiaomi, Tencent, and Ali

beginning

Recently, the circle of programmers is very lively. Not long ago, a magical open source project was 996.ICUborn, with more than 10w+ stars and 1w+ forks in a few days
. It can be described as the fastest-growing project on Github. 996.icuThe serious overtime situation of programmer 996 was brought to the public, and Internet bigwigs such as Jack Ma and Liu Qiangdong were also pushed to the forefront of public opinion because of 996's voice.

This matter only stopped for a few days, and there was another big melon in the Internet circle. This afternoon, an open source library go-commonof open source libraries aroused heated discussion among melon friends, and it reached 5000+ stars and 5000+ forks in just a few hours. After a while, it will be refreshed by a few hundred stars, and it has the momentum to catch up with 996.ICU .

ByteDance has asked this question on three sides, and I have sorted it out here. I hope it can help everyone. Welcome to check and fill in the gaps.

Separate data processing and view loading

We know that pulling data from the remote must be asynchronous. After we pull the data, we may hurriedly throw the data to the VH for processing. In fact, we should also place the data processing logic in asynchronous processing. After the Adapter notify the change, ViewHolder can do data and view binding logic simply and without pressure, such as:

mTextView.setText(Html.fromHtml(data).toString())

The Html.fromHtml(data) method here may be more time-consuming. If there are multiple TextViews, it will be more time-consuming, which will cause frame drops and freezes. If you put this step together with the network asynchronous thread From the user's point of view, the network refresh time is a little longer at most.

Data optimization

Pull remote data by page, cache the pulled remote data, improve the speed of secondary loading; for newly added or deleted data, use DiffUtil to refresh the data locally instead of blindly refreshing the data globally.

Layout optimization

Reduce transition drawing

To reduce the layout level, you can consider using a custom View to reduce the level, or set the layout more reasonably to reduce the level. It is not recommended to use ConstraintLayout in RecyclerView. Many developers have already reported that using it is worse. Related links are: Is ConstraintLayout that slow?, constraintlayout 1.1.1 not work well in listview.

Reduce xml file inflate time

The xml file here includes not only the xml of the layout, but also the xml of the drawable. The xml file inflate out the ItemView through time-consuming IO operations, especially when the probability of Item reuse is very low, as the Type increases, this The loss caused by inflate is quite large. At this time, we can use code to generate the layout, that is, the new View() method, as long as we figure out the API corresponding to the attributes of each node in the xml.

Reduce the creation of View objects

A slightly complex Item will contain a large number of Views, and the creation of a large number of Views will also consume a lot of time, so the ItemView should be simplified as much as possible; when designing the ItemType, try to design a custom View for the parts that can be shared by multiple ViewTypes to reduce the View The construction and nesting.

other

Others do not mean that they are not important, but I can't classify them. Some operations may greatly optimize your RecyclerView.

  • Upgrade RecycleView version to 25.1.0 and above to use Prefetch function, please refer to RecyclerView data prefetching.
  • If the Item height is fixed, you can use RecyclerView.setHasFixedSize(true); to avoid requestLayout wasting resources;
  • Set RecyclerView.addOnScrollListener(listener); to stop loading during the sliding process.
  • If animation is not required, you can use ((SimpleItemAnimator) rv.getItemAnimator()).setSupportsChangeAnimations(false); to turn off the default animation to improve efficiency.
  • Use String.toUpperCase for TextView instead of android:textAllCaps="true".
  • Use StaticLayout or DynamicLayout custom View for TextView instead of it.
  • Recycle resources by overriding RecyclerView.onViewRecycled(holder).
  • Use RecycleView.setItemViewCacheSize(size); to increase the cache of RecyclerView and use space for time to improve the smoothness of scrolling.
  • If the Adapter of multiple RecycledViews is the same, for example, the same Adapter exists in the nested RecyclerView, you can share a RecycledViewPool by setting RecyclerView.setRecycledViewPool(pool);.
  • Set up a listener for the ItemView. Don't call addXxListener for each Item. You should share an XxListener and perform different operations based on the ID to optimize the resource consumption caused by frequent object creation.
  • Use getExtraLayoutSpace to increase the extra space reserved by RecyclerView (outside the display range, there should be extra cache space), as shown below:
new LinearLayoutManager(this) { 
@Override protected int getExtraLayoutSpace(RecyclerView.State state) {
 return size; 
} 
};

The author switched from Java development to Android development in 2013. He has been in a small factory, and he has also been to a large factory such as Huawei and OPPO. In April of 2018, he joined Ali until now.

I have participated in many interviews and interviewed many people as an interviewer. I know that most junior and mid-level Android engineers want to improve their skills. They often grow up on their own. The unsystematic learning effect is inefficient and long, and it is easy to encounter the ceiling technology stagnation!

I have compiled a list of the most systematic Android development mainstream technologies at the Ali P7 level, which is especially suitable for in-depth learning and improvement of small partners with more than 3-5 years of experience.

Mainly include Ali, and the mainstream architecture technology of ByteDance, Tencent, Huawei, Xiaomi, and other first-line Internet companies. If you want to learn Android development in depth and become a qualified senior engineer, you can bookmark these advanced Android technology selections

I have collected and sorted out the interview questions of Alibaba, Tencent, ByteDance, Huawei, Xiaomi and other companies in the past few years, and sorted out the interview requirements and technical points into a large and comprehensive "Android Architect" interview Xmind (in fact, it is better than Expected to spend a lot of energy), including the knowledge context + branch details.

Java language and principles;
big factory, small factory. Android interview first see if you are familiar with the Java language

Advanced UI and custom view;
custom view, the basic skills of Android development.

Performance tuning;
data structure algorithms, design patterns. All of the key foundations and key points need to be skilled.

NDK development;
future direction, high salary is bound to be.

Cutting-edge technology;
componentization, hot upgrade, hot repair, frame design

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 stop studying it in depth, then it is difficult to achieve real technological improvement. I hope that this systematic technical system will provide you with a direction reference.

When I was building these technical frameworks, I also sorted out the advanced advanced tutorials of the system, which will be much better than my own fragmented learning effect, visible on GitHub; "Android Architecture Video + Study Notes"

Of course, it is not easy to learn and master these abilities in depth. Everyone knows how to learn and what kind of work intensity is as a programmer, but no matter how busy the work is, I still have to spare 2 hours a week to study.

E8%96%AA%EF%BC%81.md)**

Of course, it is not easy to learn and master these abilities in depth. Everyone knows how to learn and what kind of work intensity is as a programmer, but no matter how busy the work is, I still have to spare 2 hours a week to study.

Within half a year, you will be able to see the changes!

Guess you like

Origin blog.csdn.net/weixin_52746928/article/details/113105272