Android project Development Combat (1)--Home top menu bar implementation

Source: Internet
Author: User

From today onwards, I will begin to write my own handwritten horoscope, the data source of the constellation Horoscope uses MYAPI constellation data, the client is completely self-fulfilling.

This series is mainly about the layout of the main interface in the project and some of the difficulties in the project analysis. As I have just self-taught Android soon, please the big God to shoot bricks under mercy.

The first to talk about the implementation of the bar at the top of the home page

Now the app, as far as I can see, involves a bar at the top, the main function being hints and navigation,

First look at the actual effect


So how do you achieve such an effect?

The idea is to nest the layout of a top navigation menu in a page layout

<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http    ://schemas.android.com/apk/res/android "android:layout_width=" match_parent "android:layout_height=" Match_parent " android:orientation= "vertical" > <relativelayout android:id= "@+id/headerlayout" Android:layout_wid Th= "Fill_parent" android:layout_height= "45.0dip" android:background= "@color/title_color" > <tex TView android:id= "@+id/title" android:layout_width= "Wrap_content" android:layout_height= "            Wrap_content "android:layout_centerhorizontal=" true "android:layout_centervertical=" true " android:text= "@string/Home" android:textcolor= "#ffffffff" android:textsize= "20.0sp"/> </r Elativelayout></relativelayout> 
where android:layout_centerhorizontal= "true" android:layout_centervertical= "true" is set TextView centered, so finish writing, Loading this layout in the OnCreate method of the activity will

To achieve the effect of the top navigation menu, the activity code is as follows

protected void OnCreate (Bundle savedinstancestate) {          super.oncreate (savedinstancestate);          This.requestwindowfeature (window.feature_no_title);        Setcontentview (r.layout.main);        initcomponent ();    }  




Android project Development Combat (1)--Home top menu bar implementation

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.