Android Development Notes – create your own blog app (I) Android Development Notes – create your own blog app (II)

Recently, there have been a lot of things. Blog updates have fallen behind again. I usually have a habit. I like to look at the blog friends' articles in the blog park before going to bed, but I always feel that the blog Park client downloaded from the app market is not very comfortable to use. Recently, I found that the blog park also has an open data interface, so I plan to write a blog Park client myself.

Recently, Google has launched a new UI design specification - material design. If you don't know, look at the unofficial Chinese guide to material design. Compared with Google's mediocre performance in Android holo style, material design is now paid more attention by Google. After the launch of this new design language, Google's own applications soon used the new design of material design, such as play store, Google map, Google +, etc.

I plan to catch up with the trend, follow the pace of Google, develop this app according to the material design specification, and just let myself get familiar with Android 5 New features after 0. This app will be done slowly and gradually improve the required functions. I'm not sure I'll write a few articles. Anyway, take it out and write it when I'm free.

It is preliminarily planned to realize the user's login, classified viewing of article content and news content, including browsing, attention, preference of user information, collection of articles and offline reading function. If you have any good suggestions, you can leave me a message in the article comments and ask for advice with an open mind.

Well, back to business, let's take a look at the effect to be achieved today: (construction of UI main framework)

In the past, if we want to achieve the above effect, we will use actionbar for the top menu, slidingmenu for the side menu, slidingmenu for the viewpager sliding page indicator, and open source controls such as viewpagerindicator or pagerslidingtabstrip for the viewpager sliding page indicator. But now that Google has officially provided us with an implementation, we of course use the officially provided controls.

Implementation of side sliding menu: implementation of drawerlayout viewpager sliding page indicator: the two spaces of tablayout are in V4 package and V7 package respectively. For unfamiliar friends, check the information online.

About code implementation:

The toolbar is at the top, the sideslip menu is drawerlayout, the content of the sideslip menu is navigationview, and the main interface is viewpager embedded fragment. Look at the code directly.

First, we need to define the style. Our top no longer implements actionbar, but Google's new toolbar based on actionbar (under V7 support package):

Then, for the NavigationBar at the bottom, we need to add an additional in the values-v21 file:

Let's look at the layout file:

Main layout file: activity_ main. xml

Toolbar layout files: activity_ toolbar. xml

Sideslip menu layout file: activity_ main_ menu. xml,activity_ main_ menu_ header. xml

Menu content file: menu_ drawer_ view. XML (under menu folder)

Main content layout file: activity_ main_ content. xml

Let's look at the Java code:

Primary activity:

Main sliding page viewpager adapter:

As for the fragment carried by viewpager, it will not be posted here. It is very simple to display a textview.

Write here today and continue to update another day. If you have any suggestions or questions, you can leave me a message in the article comments.

Next: Android Development Notes - building your own blog app (2)

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