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