In the previous article, we have completed the data model code, and for the convenience of testing, the default values are directly provided for many member variables in the class. Next, go to the interface section.
The entire interface can be divided into two parts: one is the top operation bar and the other is the list box that occupies the body.
Start with the operation bar at the top. Here, it is easy to break down into three parts: the Weibo button on the left, the username in the middle, and the refresh button on the right. The two buttons have the same style, both in the regular and pressed states. These buttons are very common. My approach is:
1. Create two XML files in the drawable folder, which correspond to two buttons respectively;
2. Use the selector label in each XML file to define two image resources in the regular and selected states;
3. Use imagebutton in the activity layout, specify the button's background as transparent, and specify SRC as the two XML files just defined.
The content of these two XML files is as follows:
<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <selector xmlns: Android = "http://schemas.android.com/apk/res/android"> <br/> <item Android: state_pressed = "true" Android: drawable = "@ drawable/title_new_selected"/> <br/> <item Android: drawable = "@ drawable/title_new_normal"/> <br/> </selector>
<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <selector xmlns: Android = "http://schemas.android.com/apk/res/android"> <br/> <item Android: state_pressed = "true" Android: drawable = "@ drawable/title_reload_selected"/> <br/> <item Android: drawable = "@ drawable/title_reload_normal"/> <br/> </selector>
In the main. xml file, this part of the layout has a clear positional relationship for the three interface elements. Therefore, it is appropriate to use relativelayout. The content is as follows:
<Relativelayout <br/> Android: layout_width = "fill_parent" Android: layout_height = "44dp" <br/> Android: Background = "@ drawable/titlebar_lightgray_bg" Android: orientation = "horizontal"> <br/> <imagebutton Android: Id = "@ + ID/btnwrite" <br/> Android: layout_width = "wrap_content" Android: layout_height = "fill_parent" <br/> Android: layout_alignparentleft = "true" Android: Background = "@ Android: color/transparent" <br/> Android: src = "@ drawable/write_button"> <br/> </imagebutton> <br/> <textview Android: Id = "@ + ID/textviewusername" <br/> Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" <br/> Android: textcolor = "@ color/Black" Android: gravity = "center" Android: textsize = "18sp"> <br/> </textview> <br/> <imagebutton Android: Id = "@ + ID/btnrefresh" <br/> Android: layout_width = "wrap_content" Android: layout_height = "fill_parent" <br/> Android: layout_alignparentright = "true" Android: Background = "@ Android: color/transparent "<br/> Android: src =" @ drawable/refresh_button "> <br/> </imagebutton> <br/> </relativelayout>
Finally, specify the background of relativelayout as the background image.
The images used this time include:
-- Welcome to reprint, please indicate the source of http://blog.csdn.net/caowenbin --