All Projects → xiaohaibin → CustomTitleBar

xiaohaibin / CustomTitleBar

Licence: other
💥【通用标题栏】通用Android标题栏控件 A Common Titlebar For Android

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to CustomTitleBar

Blurimage
This Android Project help you to make your image blur in fastest way
Stars: ✭ 162 (+52.83%)
Mutual labels:  customview
Colorseekbar
A colorful SeekBar for picking color
Stars: ✭ 249 (+134.91%)
Mutual labels:  customview
HenCoderPractice-Kotlin
HenCoder 练习项目- Kotlin 版
Stars: ✭ 26 (-75.47%)
Mutual labels:  customview
Searchview
This a view that waiting for network connection to resolve with cool animation .
Stars: ✭ 174 (+64.15%)
Mutual labels:  customview
Cameravideobutton
Instagram like animated button for taking photo or recording video.
Stars: ✭ 223 (+110.38%)
Mutual labels:  customview
TitleBar
🔥空祖家的标题栏组件
Stars: ✭ 36 (-66.04%)
Mutual labels:  titlebar
Codeeditor
Code Editor Native Way
Stars: ✭ 155 (+46.23%)
Mutual labels:  customview
WechatPopupWindow
高仿微信聊天界面长按弹框样式
Stars: ✭ 71 (-33.02%)
Mutual labels:  customview
Xmarqueeview
💥【MarqueeView】类似淘宝头条、京东头条的跑马灯效果,上下轮播,支持单行/多行显示、自定义轮播布局
Stars: ✭ 224 (+111.32%)
Mutual labels:  customview
TriangularCustomView
No description or website provided.
Stars: ✭ 29 (-72.64%)
Mutual labels:  customview
Speedometer
A lightweight circular indicator view library for Android
Stars: ✭ 183 (+72.64%)
Mutual labels:  customview
Jackknife
⚔️ 金轮法王,哦不,是轮子大师带你玩转Android,是时候尝试下MVVM了。这是一个Android应用开发全家桶库,支持Kotlin+MVVM+Dagger2+Retrofit架构。
Stars: ✭ 215 (+102.83%)
Mutual labels:  customview
electron-react-titlebar
A github desktop style title bar component for electron.
Stars: ✭ 53 (-50%)
Mutual labels:  titlebar
Timeline
瀑布流式的时间轴
Stars: ✭ 2,028 (+1813.21%)
Mutual labels:  customview
SuperShapeView
A smart custom view support shapes for ImageView, TextView ,EditView ,instead of shape.xml.(自定义形状控件,支持TextView,EditText)
Stars: ✭ 60 (-43.4%)
Mutual labels:  customview
Rangeview
Android range view for cropping (video, audio, etc.)
Stars: ✭ 157 (+48.11%)
Mutual labels:  customview
smart borders
awesomewm full titlebar functionality without sacrificing space
Stars: ✭ 51 (-51.89%)
Mutual labels:  titlebar
MEMiniMe
Makes the toolbars in Big Sur small
Stars: ✭ 64 (-39.62%)
Mutual labels:  titlebar
TitlebarZ
A simple titlebar customizer for Windows 10.
Stars: ✭ 21 (-80.19%)
Mutual labels:  titlebar
Androidproject
Android 技术中台,但愿人长久,搬砖不再有
Stars: ✭ 4,398 (+4049.06%)
Mutual labels:  titlebar

CustomTitleBar

通用Android标题栏控件,本控件是基于 QMUI_Android 中的标题栏控件抽取出来,单独封装使用的,在此感谢QMUI团队的开源项目。

主要功能:

  • 支持左、右 文字、图片按钮
  • 支持主、副标题
  • 支持自定义左右按钮图片、文字样式及标题文字样式
  • 支持全局设置标题主题样式

效果图

1

基本使用(详细的使用方法可以参考demo)

Download

1.添加Gradle依赖

dependencies {
    compile 'com.xhb:commontitlebar:latestVersion'//将latestVersion替换成上面最新的版本号
}

2.在布局文件中添加

    <com.stx.xhb.commontitlebar.CustomTitleBar
        android:id="@+id/titlebar"
        android:layout_width="match_parent"
        android:layout_height="?attr/titlebar_height"/>

3.在styles文件中配置主题


<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="config_color_divider">@color/divider</item>
        <!--标题栏主题样式-->
        <item name="CustomTitleBarStyle">@style/QDTopBar</item>
        <!--设置标题栏高度-->
        <item name="titlebar_height">56dp</item>
    </style>

    <style name="QDTopBar" parent="CustomTitleBar.TopBar">
        <item name="titlebar_bg_color">@color/colorAccent</item>
        <item name="titlebar_title_text_size">16sp</item>
        <item name="titlebar_title_color">@color/color_white</item>
        <item name="titlebar_subtitle_color">@color/config_color_white</item>
        <item name="titlebar_text_btn_color_state_list">@color/s_topbar_btn_color</item>
        <item name="titlebar_image_btn_height">48dp</item>
    </style>

</resources>

4.在Activity或者Fragment中配置

       CustomTitleBar mTopBar = (CustomTitleBar) findViewById(R.id.titlebar);
       
        mTopBar.addLeftImageButton(R.mipmap.ic_launcher,R.id.topbar_left_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "测试", Toast.LENGTH_SHORT).show();
            }
        });
        
        mTopBar.addLeftBackImageButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "测试", Toast.LENGTH_SHORT).show();
            }
        });
        
        mTopBar.addRightTextButton("呵呵",R.id.topbar_right_about_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "呵呵", Toast.LENGTH_SHORT).show();
            }
        });
        
         //代码中设置样式
    titleBar2.addRightTextButton("完成",R.id.topbar_right_about_button,ContextCompat.getColorStateList(this,R.color.color_black),16).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "完成", Toast.LENGTH_SHORT).show();
            }
        });

自定义属性说明

属性名 属性说明 属性值
titlebar_title_gravity 标题gravity,用于控制 title 和 subtitle 的对齐方式 默认为Gravity.CENTER
titlebar_show_divider 是否显示分割线 boolean 类型 ,默认显示
titlebar_divider_color 分割线颜色 color
titlebar_divider_height 分割线高度 dimension 类型,默认为1px
titlebar_bg_color 标题栏背景颜色 color 类型,默认为 Color.WHITE
titlebar_left_back_drawable_id 左侧返回按钮图片资源id reference
titlebar_title_text_size 标题文字大小 dimension 类型,默认为17sp
titlebar_title_text_size_with_subtitle 有副标题下的标题文字大小 dimension 类型,默认为16sp
titlebar_subtitle_text_size 副标题文字大小 dimension 类型,默认为11sp
titlebar_title_color 标题文字颜色 color
titlebar_subtitle_color 副标题文字颜色 color
titlebar_title_margin_horizontal_when_no_btn_aside 左右没有按钮时,title 距离 TopBar 左右边缘的距离 dimension,默认为0dp
titlebar_title_container_padding_horizontal 包裹 title 和 subTitle 的容器横向内边距 dimension 类型,默认0dp
titlebar_image_btn_width 图片按钮宽度 dimension,默认48dp
titlebar_image_btn_height 图片按钮高度 dimension,默认48dp
titlebar_text_btn_padding_horizontal 文本按钮横向内边距 dimension 类型,默认12dp
titlebar_text_btn_color_state_list 文字按钮点击状态 reference 类型
titlebar_text_btn_text_size 按钮文字大小 dimension 类型,默认16sp

关于我

如果觉得文章帮到你,喜欢我的文章可以关注我和朋友一起运营的微信公众号,将会定期推送优质技术文章,求关注~~~

欢迎关注“大话安卓”微信公众号

欢迎加入“大话安卓”技术交流群,一起分享,共同进步

欢迎加入“大话安卓”技术交流群,互相学习提升

License

Copyright (C) 2016 [email protected]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].