How to Create titlebar for common Android UIS

Source: Internet
Author: User

Many Android applications have Fixed UI designs. For example, many applications have titlebar and tabbar. Here I will write out the production methods of various Fixed UI components I encountered during my work.
Titlebar (title bar) is particularly widely used and mainly serves as a prompt and navigation. The controls involved in the components include ImageView and TextView (this is not unique here, depending on your production method ). Next I will introduce my practices, first paste the main. xml code and.
The Code is as follows:
1 <? Xml version = "1.0" encoding = "UTF-8"?>
2 <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
3 android: orientation = "vertical"
4 android: layout_width = "fill_parent"
5 android: layout_height = "fill_parent"
6 android: background = "@ drawable/background">
7
8 <RelativeLayout android: layout_width = "fill_parent"
9 android: layout_height = "wrap_content"
10 android: background = "@ drawable/toolbar_background">
11
12 <RelativeLayout android: id = "@ + id/toolbar_left"
13 android: layout_width = "wrap_content"
14 android: layout_height = "wrap_content"
15 android: layout_alignParentLeft = "true"
16 android: layout_centerVertical = "true"
17 android: layout_marginLeft = "10dip"
18 android: clickable = "true">
19 <ImageView android: id = "@ + id/toolbar_left_image"
20 style = "@ style/toolbar_left_button_image"/>
21 <TextView android: id = "@ + id/toolbar_left_text"
22 android: text = "@ string/toolbar_return"
23 android: layout_alignTop = "@ id/toolbar_left_image"
24 android: layout_alignLeft = "@ id/toolbar_left_image"
25 style = "@ style/toolbar_left_button_text"/>
26 </RelativeLayout>
27
28 <RelativeLayout android: layout_width = "wrap_content"
29 android: layout_height = "wrap_content"
30 android: layout_centerInParent = "true">
31 <TextView android: layout_width = "wrap_content"
32 android: layout_height = "wrap_content"
33 android: text = "@ string/toolbar_everydaytip"
34 style = "@ style/toolbar_text"/>
35 </RelativeLayout>
36
37 <RelativeLayout android: id = "@ + id/toolbar_right"
38 android: layout_width = "wrap_content"
39 android: layout_height = "wrap_content"
40 android: layout_alignParentRight = "true"
41 android: layout_centerVertical = "true"
42 android: layout_marginRight = "10dip"
43 android: clickable = "true">
44 <ImageView android: id = "@ + id/toolbar_right_image"
45 style = "@ style/toolbar_right_button_image"/>
46 <TextView android: id = "@ + id/toolbar_right_text"
47 android: text = "@ string/toolbar_index"
48 android: layout_alignTop = "@ id/toolbar_right_image"
49 android: layout_alignLeft = "@ id/toolbar_right_image"
50 style = "@ style/toolbar_right_button_text"/>
51 </RelativeLayout>
52
53 </RelativeLayout>
54
55 </LinearLayout>
The figure is as follows:

RelativeLayout is used to implement refined layout control.

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.