Detailed explanation of the layout example of Android development high imitation Curriculum

Let's talk about this demo first. It's a layout file that imitates the curriculum. Although I'm a rookie, I still want to leave some examples for learners to see the effect first

Then take a look at our school app

Layout analysis

Let's start with a divided layout

First, the whole page is placed under a linear layout, which is divided into two parts: the upper part and the lower part. The lower part displays the details of the curriculum

1: There is nothing to say about this, that is, directly a LinearLayout layout, and then use a textview to display the year, a view as a vertical bar, and a spinner to display the selected weeks

2: This is the part to display the day of the week. It is my custom view. Rewrite the OnDraw method and draw seven words. The code is as follows:

3: This is also a LinearLayout. Directly write the layout, and set the orientation property of LinearLayout to vertical.

4: This is a GridView, and then inherit the baseadapter to fill in the content, and put the layout XML file below

The following is the adapter code of GridView:

Let's explain it slowly. First, to customize the adapter, we must inherit an adapter. Here, we inherit from baseadapter. After inheritance, we must rewrite getcount (), getitem (int), getitemid (int), getview (int, view, ViewGroup). These methods must be rewritten. The most important thing is to rewrite the getview () method, because this method returns a view, Then it is the layout of each sub item of the GridView.

This line of code loads the layout file and returns a view

The code here is to judge each column and then change the background of the view. The background code is as follows:

Others are similar to the layout file of item:

This is to imitate the layout of the curriculum, and finally attach the source code git address: click me to download

The above is a detailed explanation of the layout example of Android development high imitation curriculum introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

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
分享
二维码
< <上一篇
下一篇>>