Establish the basic layout of each window

Wechat window has four sliding Windows, but each window has the same bottom view area and the same upper small window. Therefore, we can create two sub-XML files named top and bottom respectively, which can simulate the establishment of the upper and lower layout of wechat interface.

1. Design of top page.

Create a horizontal LinearLayout XML file and add a TextView to it, as shown below:

2. Bottom page design

Create a horizontal LinearLayout XML file and add four vertical LinearLayouts to it. Add an imageView and a TextView to each of the four LinearLayouts. The specific properties are shown in the figure below:

Two. Page add combination

Include the bottom and top pages to the home page and add a FrameLayout control to the home page.

3. Add Fragment and implement dynamic switching

Add four fragments as shown in the figure

The Java file code for each Fragment is shown below:

Define four Linearlayout objects and four ImageView objects and set four Linearlayout listeners.

Set the click listen event

The replace function is used to replace the Fragment in FrameLayout, and the change function is used to control the corresponding icon change after clicking.

Iv. Effect display

5. Summary

The basic window design of wechat is relatively simple, and my code can be simplified. This experiment design still gives me a deeper understanding of AS and a better concept of some of the controls. I will continue to learn.

Attached source code address :link.juejin.cn/?target=htt…