Android Design Support Library high-forcing leopard production course

Source: Internet
Author: User
Tags xmlns

The recent project is not very busy, finally have time to write a blog, take advantage of these days with some of the new features of Android to write the leopard frame, first look at the picture, and before the original version do not know what people prefer.


A few days ago Devin to me opened a VPN, as Google brain residue powder, silently downloaded a variety of the latest tools, with my love for the material design, officially began to chew Google official website. The technology is never finished, actually two months ago, I have learned some material design, I have not had time to use, now that part of the content has been eliminated, discarded technology ...

Ok, this time to explain the use of the Navigationview, this is the Android Lolipop in the Android Design Support Library to bring the material design components launched, The components also contains floating labels for editing text, a floating action button, Snackbar, and tabs.

Google's explanation:

The navigation drawer can be a important focal point for identity and navigation within
Your app and consistency in the ' design ' can make a considerable difference in ' and ' Easy your ' app is to navigate, partic Ularly for the. Navigationview makes this easier by providing of the framework you are need for the navigation as as as as is the drawer to I Nflate your navigation items through a menu resource.

Previously, Drawertoolge+actionbar is standard, such as Google's own googleplay, and this time Google means navigationbar more easy to use, only need to fill the menu resources to achieve, Basically do not need to consider too much logic, Google has been actionbar and scrapped, using toolbar to replace, this side by the way of experience, this is also a bug in the past few days, is to pay attention to Google discarded things, to remain vigilant prepared, I used to think it was no big deal to waste an API, but in this latest update, Google scrapped an API for Apache, which makes the asynchronous request I'm using no longer available, and that day was lucky, Just read the official Google update to mention this waste API and solution, otherwise this bug is not possible to solve, because the problem is too new, direct search, the basic impossible to find a solution, can only change a way of request, This also makes me understand why Daniel is recommending Google to find the answer to the reason, the bug in Baidu to find estimates have to wait for a year or at all can not find.
To come to the side, using navigation needs to be paired with Drawerlayout.


<android.support.v4.widget.drawerlayout
Xmlns:android= "Http://schemas.android.com/apk/res/android"
xmlns:app= "Http://schemas.android.com/apk/res-auto"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
Android:fitssystemwindows= "true" >
<!--your content layout-->
<android.support.design.widget.navigationview
Android:layout_width= "Wrap_content"
android:layout_height= "Match_parent"
Android:layout_gravity= "Start"
app:headerlayout= "@layout/drawer_header"
app:menu= "@menu/drawer"/>
</android.support.v4.widget.DrawerLayout>

The header layout is the same as normal XML, mainly written by Menu_drawer.
There are two main ways: 1, group within the Fill item 2, item can contain the word item

The following is an official Google example:

The simplest drawer menus would be a collection of checkable menu items:

<group android:checkablebehavior= "single" >
<item
Android:id= "@+id/navigation_item_1"
Android:checked= "true"
android:icon= "@drawable/ic_android"
android:title= "@string/navigation_item_1"/>
<item
Android:id= "@+id/navigation_item_2"
android:icon= "@drawable/ic_android"
android:title= "@string/navigation_item_2"/>
</group>
The checked item would appear highlighted in the navigation drawer ensuring the user knows which the item is navigation tly selected.

The selected item will automatically highlight the user.


<item
Android:id= "@+id/navigation_subheader"
android:title= "@string/navigation_subheader" >
<menu>
<item
Android:id= "@+id/navigation_sub_item_1"
android:icon= "@drawable/ic_android"
android:title= "@string/navigation_sub_item_1"/>
<item
Android:id= "@+id/navigation_sub_item_2"
android:icon= "@drawable/ic_android"
android:title= "@string/navigation_sub_item_2"/>
</menu>
</item>

Listening:

Onnavigationitemselectedlistener using Setnavigationitemselectedlistener (). This is provides with the MenuItem of that is clicked, allowing you to handle selection events, changed the checked status, Load new content, programmatically close to the drawer, or any of the other actions to your may want.
The Navigationview interface is well written. Set Setnavigationitemselectedlistener () of listening, passing parameters, will be passed to the onnavigationitemselected in the MenuItem to the user, in this way to achieve operation.

More content I will continue to organize the release later, as long as time allows, Google introduced new technology I will be the first time to learn and organize the release

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.