GithubHelp home page GithubHelp logo

customtitlebar's Introduction

CustomTitleBar

一款项目中常用的标题样式

主要功能:

  • 支持左、右按钮
  • 支持按钮点击背景
  • 支持自定义左右按钮图片、文字样式及标题文字样式

效果图

1

基本使用

Download

1.Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
	

Step 2. Add the dependency

  dependencies {
           compile 'com.github.yanjiabin:CustomTitleBar:1.0'
   }

2.在布局文件中添加

    <com.yanjiabin.costomtitlebarlib.CustomTitlebar
        android:id="@+id/title3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:title_text="标题"
        app:left_button_image="@mipmap/icon_back"
        app:title_textSize="14sp"
        app:right_button_image="@mipmap/img_currency_selected"/>

3.在Activity或者Fragment中配置

        CustomTitlebar customTitlebar2 = (CustomTitlebar) findViewById(R.id.title2);
        customTitlebar2.setAction(new CustomTitlebar.TitleBarOnClickListener() {
            @Override
            public void performAction(View view) {
                switch (view.getId()){
                    case R.id.iv_left:
                        Toast.makeText(MainActivity.this, "左边图片按钮", Toast.LENGTH_SHORT).show();
                        break;
                    case R.id.tv_right:
                        Toast.makeText(MainActivity.this, "右边文字按钮", Toast.LENGTH_SHORT).show();
                        break;
                }
            }
        });

自定义属性说明

属性名 属性说明 属性值
title_background 标题栏背景色 color,默认为white
left_button_image 左边图片按钮背景 reference ,不设置则不显示
left_button_text 左边文字按钮内容 string
left_button_textColor 左边文字按钮文字颜色 color,默认为Color.GRAY
left_button_textSize 左边文字按钮文字大小 dimension,默认为14sp
title_text 标题文字内容 string
title_textColor 标题文字颜色 color,默认为Color.GRAY
title_textSize 标题文字大小 dimension,默认为14sp
right_button_image 右边图片按钮背景 reference ,不设置则不显示
right_button_text 右边文字按钮内容 string
right_button_textColor 右边文字颜色 color,默认为Color.GRAY
right_button_textSize 右边文字大小 dimension,默认为14sp
show_line 是否显示顶部分割线 booleanT类型,默认显示

关于我

个人邮箱:[email protected] GitHub主页 个人博客

#如果喜欢,还请statr&Fork&follow进行支持,谢谢O(∩_∩)O~。#

customtitlebar's People

Contributors

yanjiabin avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.