titlelayout--an Android easy-to-use title bar library for Universal, standard, immersive status bar

Source: Internet
Author: User

Titlelayout

Versatile, versatile, can be used in layout or Java code to implement the title bar, support the immersive status bar, support the left back button (do not need to manually implement the page return), the left supports picture + text, pictures, text, the right side support pictures, text and so on.

Heap code is not easy, star support, thank you click to view welcome attention:
    • [Github Address: Https://github.com/SibreiaDante]
    • [Blog Park: http://www.cnblogs.com/shen-hua/]

      Android Development Standing tool collation Gradle dependencies:
         compile ‘com.github.SiberiaDante:TitleLayout:v1.1.0‘
Use in layouts:
<com.siberiadante.titlelayoutlib.titlebarlayout android:id= "@+id/title_layout_one" android:layout_width= " Match_parent "android:layout_height=" Wrap_content "dante:d_is_back_view=" true "dante:d_is_immersive_s Tate_bar= "true" dante:d_left_image= "@mipmap/back_gray" dante:d_left_image_padding_start= "10DP" Dante: D_left_image_width= "30DP" dante:d_left_text= "test" dante:d_left_text_style= "normal" dante:d_left_text_c Olor= "@color/black" dante:d_left_text_padding_start= "10DP" dante:d_left_text_size= "14SP" Dante:d_line _height= "1px" dante:d_right_text= "Report" dante:d_right_text_size= "14SP" dante:d_right_text_style= "normal        "Dante:d_right_text_color=" @color/white "dante:d_title_size=" 18sp "dante:d_title_style=" Mormal " Dante:d_title_text= "Here is the title" dante:d_title_color= "@color/black" dante:d_subtitle_size= "11SP" dante:d _subtitle_style= "Mormal"        Dante:d_subtitle_text= "Here is the subtitle" dante:d_subtitle_color= "@color/gray" dante:d_title_layout_background= "@color/red" dante:d_title_layout_height= "45DP"/>
Using Java code:
  TitleBarLayout titleBarLayout = (TitleBarLayout) findViewById(R.id.title_layout);        titleBarLayout.setTitleClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                LogUtil.d("title 被点击了");            }        });        //设置Titlesize        titleBarLayout.setTitleSize(30);        //一键设置标题样式        titleBarLayout.setTitleStyle("我是标题", 18, ContextCompat.getColor(this, R.color.action_sheet_blue));        titleBarLayout.setRightImageClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                LogUtil.d("右边图片被点击了");            }        });
Key notes:
    • If the left text or button is a return key, you only need to use the following code in the layout:

      dante:d_is_back_view="true"

      Or in Java code

      titleLayout.setIsLeftBackView(true)

      No need to set onclicklistener,this.finish, etc., if special needs, can set the property to False, the implementation method:

      setLeftClickListener(OnClickListener listener)
    • If an immersive status bar is used in your project, you need to

      dante:d_is_immersive_state_bar="true"
    • To set the page as an immersive status bar method:

       ScreenUtil.setStatusTranslucent(this);
Other properties describe the attributes in the XML:
XML properties Property Description
D_left_image Picture resources on the left
D_left_image_width Left picture width (high to match parent layout)
D_left_image_padding_start Left margin of picture (default 10DP)
D_left_text Left text resource
D_left_text_size Left text size (default 16SP)
D_left_text_color Left text color (default black)
D_left_text_style Set Text Style (Normal|bold|italic)
D_left_text_padding_start Left text left margin (default 10DP)
D_title_text Middle Title Text Resource
D_title_size Middle Title text size (default 18SP)
D_title_color Middle Caption text color (default black)
D_title_style Set Text Style (Normal|bold|italic)
D_subtitle_text Middle Subtitle Text Resource
D_subtitle_size Middle subtitle Text Size (default 12SP)
D_subtitle_color Middle subtitle text color (default black)
D_subtitle_style Set Text Style (Normal|bold|italic)
D_right_text Right text resource
D_right_text_color Right text color
D_right_text_size Right text size (default 16SP)
D_right_text_style Set Text Style (Normal|bold|italic)
D_right_text_padding_end Right text distance to right margin
D_right_image Right picture Resource
D_right_image_width Right picture width, height to match parent layout
D_right_image_padding_end Right margin from right side
D_line_height title bar Bottom horizontal line height (default 1px, recommended units using PX)
D_line_background title bar bottom horizontal line background color (default black)
D_title_layout_height Title bar Overall height (default 45DP)
D_title_layout_background Title bar overall background color
D_is_back_view The left text and the picture is the return key, if return the key, then comes back with the previous page function
D_is_immersive_state_bar Whether it is an immersive status bar, false by default (True when the title bar height contains the status bar height)
In the Java code
Java Code methods Java Code Method description
Settitle (charsequence title) Set up a title resource
settitlesize (int titlesize) Set Title font size
Settitlecolor (int titlecolor) Set Title Font Color
Settitlestyle (String title, int titlesize, int titlecolor) Set title resource, text size, text color
Setsubtitle (charsequence title) Set up subtitle Resources
setsubtitlesize (int titlesize) Set subtitle font size
Setsubtitlecolor (int titlecolor) Set Subtitle Font Color
Setsubtitlestyle (String title, int titlesize, int titlecolor) Set subtitle resource, text size, text color
Setlefttext (String lefttext) Set left text
setlefttextsize (int lefttextsize) Set the left text size
Setlefttextcolor (int lefttextcolor) Set the left text color
Setleftstyle (String lefttext, int lefttextsize, int lefttextcolor) Set left text, text size, text color
Setrighttext (String righttext) Set Right text
setrighttextsize (int righttextsize) Set the right text size
Setrighttextcolor (int righttextcolor) Set the right text color
Settitleclicklistener (Onclicklistener Listener) Title Click to listen
Setleftclicklistener (Onclicklistener Listener) Left text and button click to listen
Setrighttextclicklistener (Onclicklistener Listener) Right text click to listen
Setrightimageclicklistener (Onclicklistener Listener) Right button tap Listen
Setisleftbackview (Boolean Isleftbackview) Sets whether the left text and buttons are return buttons
Setishaveline (Boolean Haveline) Set whether there are split lines at the bottom of the title bar
Setleftbackviewvisible Set left icon to show hidden
Setlefttextviewvisible Set left text display hidden
Setrighttextviewvisible Set the right text to show hidden
Setrightimageviewvisible Set the right icon to show hidden
Settitlevisible Set caption Display hidden
Setsubtitlevisible Set subtitle display hidden
Problem
    • To set the font color distortion, use: Contextcompat.getcolor (this,r.color.red)
Update optimization Instructions
    • v1.1.0:
      • Added support for Java code settings all controls Show hidden
    • v1.0.9:
      • Added support for dynamic setting of left and right icon functions
      • Add Unsupportedoperationexception exception prompt when uninitialized
    • v1.0.4
      • Fix bugs
      • Support for setting Text style (Normal|bold|italic)
    • v1.0.2
      • Added support subtitle feature
      • Optimize title too long display problem
    • v1.0.1
      • Versatile, versatile, can be used in the layout or the use of Java code implementation of the title bar;
      • Support for immersive status bar;
      • Support left return button does not need to manually implement page return;
      • Support left button, middle title, right button click
      • The left side supports picture + text, individual pictures, individual text, the right side supports individual pictures, individual text, etc.
      • Versatile, versatile, can be used in the layout or the use of Java code implementation of the title bar;
      • Support the immersive status bar, support the left back button (do not need to manually implement the page return), the left supports picture + text, pictures, text, the right support pictures, text and so on.

titlelayout--an Android easy-to-use title bar library for Universal, standard, immersive status bar

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.