Android activity and fragment implement bottom navigator

Bottom navigator with single activity and multiple fragments

Recently, due to the need to explain the basic knowledge of Android, a single activity and multiple fragments are adopted to realize the example of QQ bottom navigator. This development mode is widely used in app development, such as QQ, wechat, Sina, etc. there are many ways to realize the navigation bar at the bottom of Android, and there are various implementations, At the same time, Google has also added bottom navigation navigation control in its own material design, which is simpler to implement and supports more cool dynamic effects. However, because it is basic knowledge, it plans to implement it through customization without using bottom navigation (if it is an actual project development, it can be considered to use ha ~ ~), hoping to be helpful to beginners.

Bottomnavigationbar address: https://github.com/Ashok-Varma/BottomNavigation

analysis

The overall area is divided into two parts: the navigation area at the bottom and the rest of the content area. The content area is most UI displayed by using fragment. Click the click event in the navigation area at the bottom, click tab to switch the fragment, and switch the font color and picture. In the switching, add() and hide() are used instead of duplicate(). As for the difference between the two, it will not be explained here, If you are interested, you can Google.

Overall structure

The bottom navigation is usually composed of pictures and text, with ImageView above and textview below

Bottom navigation

Bottom

Use the layout, use relativelayout, add weight and divide the screen width equally

activity_ main. xml

MainActivity

The four fragments are just a simple layout. A textview is placed in it. O.o. will not be posted here

Effect preview:

design sketch

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>