All Projects → getActivity → Titlebar

getActivity / Titlebar

Licence: apache-2.0
Android 标题栏框架,从此布局属性不用记

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Titlebar

ELeMaList
仿饿了么商品列表页面
Stars: ✭ 43 (-95.61%)
Mutual labels:  toolbar, coordinatorlayout
CoolCoodinatorLayout
banner沉浸式+滚动视差+悬浮搜索框+标题置顶复杂联动效果
Stars: ✭ 46 (-95.31%)
Mutual labels:  toolbar, coordinatorlayout
Alipayhome
高仿支付宝首页的头部伸缩动画(使用design实现效果,CoordinatorLayout+AppBarLayout+CollapsingToolbarLayout+Toolbar)
Stars: ✭ 164 (-83.27%)
Mutual labels:  coordinatorlayout, toolbar
Materialdesignsamples
Material Design 系列控件samples,讲了Material Design 系列新控件的使用方法和一些场景示例,使用详情请看对应博客,持续更新中...
Stars: ✭ 900 (-8.16%)
Mutual labels:  coordinatorlayout, toolbar
Androidnavigation
A library managing navigation, nested Fragment, StatusBar, Toolbar for Android
Stars: ✭ 636 (-35.1%)
Mutual labels:  toolbar
Uiwidget
一个集成TabLayout、UIAlertDialog、UIActionSheetDialog、UIProgressDialog、TitleBarView(自带沉浸式标题栏)、CollapsingTitleBarLayout、RadiusView(圆角及状态背景设置View解放shape文件)、KeyboardHelper(软键盘控制及遮挡控制类)、StatusViewHelper(状态栏沉浸帮助类)、NavigationViewHelper(导航栏沉浸式帮助类)、AlphaViewHelper(View透明度控制帮助类) 等项目常用UI库
Stars: ✭ 400 (-59.18%)
Mutual labels:  toolbar
Extended text
A powerful extended official text for Flutter, which supports Speical Text(Image,@somebody), Custom Background, Custom overFlow, Text Selection.
Stars: ✭ 345 (-64.8%)
Mutual labels:  toolbar
Vxe Table
🐬 vxe-table vue 表格解决方案
Stars: ✭ 4,242 (+332.86%)
Mutual labels:  toolbar
Awesomebar
Just beautiful
Stars: ✭ 870 (-11.22%)
Mutual labels:  toolbar
Android Titlebar
🔥 通用,功能全面的自定义标题栏,支持沉浸式标题栏,颜色渐变,miui9
Stars: ✭ 925 (-5.61%)
Mutual labels:  toolbar
Learn Coordinatorlayout Behavior
CoordinatorLayout 自定义Behavior 高仿美团商家详情界面 实现页面内容复杂联动效果
Stars: ✭ 527 (-46.22%)
Mutual labels:  coordinatorlayout
Coordinatortablayout
Combination of TabLayout and CoordinatorLayout./TabLayout和CoordinatorLayout相结合的折叠控件
Stars: ✭ 4,114 (+319.8%)
Mutual labels:  coordinatorlayout
Multiline Collapsingtoolbar
A modified CollapsingToolbarLayout that can deal with multiline titles
Stars: ✭ 767 (-21.73%)
Mutual labels:  toolbar
Toolbarpanel
Toolbar that can be slided down to show a panel
Stars: ✭ 397 (-59.49%)
Mutual labels:  toolbar
Wsl Windows Toolbar Launcher
Adds linux GUI application menu to a windows toolbar
Stars: ✭ 918 (-6.33%)
Mutual labels:  toolbar
Scalinglayout
With Scaling Layout scale your layout on user interaction.
Stars: ✭ 3,276 (+234.29%)
Mutual labels:  coordinatorlayout
Toolbar
Awesome autolayout Toolbar. Toolbar is a library for iOS. You can easily create chat InputBar.
Stars: ✭ 458 (-53.27%)
Mutual labels:  toolbar
Android Animated Menu Items
The example Android project of animated menu items in toolbar
Stars: ✭ 923 (-5.82%)
Mutual labels:  toolbar
Immersivedetailsample
A sample application show how to realize immersive parallax effect header like Google Play Store
Stars: ✭ 457 (-53.37%)
Mutual labels:  toolbar
Bubbletab
Put some bubble in your tabs and give your apps a supa fresh style !
Stars: ✭ 537 (-45.2%)
Mutual labels:  toolbar

标题栏框架

5.0 版本、5.0 版本、5.0 版本 XML 属性已经改头换面了,请尽快进行适配

集成步骤

dependencies {
    // 标题栏框架:https://github.com/getActivity/TitleBar
    implementation 'com.hjq:titlebar:8.5'
}

属性大全,如何适配旧版本的属性?

<declare-styleable name="TitleBar">
    <!-- 整体样式 -->
    <attr name="barStyle">
        <enum name="light" value="0x10" />
        <enum name="night" value="0x20" />
        <enum name="transparent" value="0x30" />
        <enum name="ripple" value="0x40" />
    </attr>
    <!-- 中间 -->
    <attr name="title" format="string" />
    <attr name="titleColor" format="color" />
    <attr name="titleSize" format="dimension" />
    <attr name="titleGravity">
        <flag name="left" value="0x03" />
        <flag name="right" value="0x05" />
        <flag name="center" value="0x11" />
        <flag name="start" value="0x00800003" />
        <flag name="end" value="0x00800005" />
    </attr>
    <attr name="titleStyle">
        <flag name="normal" value="0" />
        <flag name="bold" value="1" />
        <flag name="italic" value="2" />
    </attr>
    <!-- 左边 -->
    <attr name="leftTitle" format="string"/>
    <!-- leftIcon 优先于 backButton -->
    <attr name="leftIcon" format="reference" />
    <attr name="leftTint" format="color" />
    <!-- 返回按钮(默认开) -->
    <attr name="backButton" format="boolean" />
    <attr name="leftColor" format="color" />
    <attr name="leftSize" format="dimension" />
    <attr name="leftBackground" format="reference|color" />
    <!-- 右边 -->
    <attr name="rightTitle" format="string" />
    <attr name="rightIcon" format="reference" />
    <attr name="rightTint" format="color" />
    <attr name="rightColor" format="color" />
    <attr name="rightSize" format="dimension" />
    <attr name="rightBackground" format="reference|color" />
    <!-- 分割线 -->
    <attr name="lineVisible" format="boolean" />
    <attr name="lineColor" format="reference|color" />
    <attr name="lineSize" format="dimension" />
    <!-- 图标显示大小 -->
    <attr name="drawableSize" format="dimension" />
    <!-- 图标和文字的间距 -->
    <attr name="android:drawablePadding" />
    <!-- 控件水平内间距 -->
    <attr name="android:paddingVertical" />
    <!-- 控件垂直内间距(可用于调整标题栏自适应的高度) -->
    <attr name="android:paddingHorizontal" />
</declare-styleable>

XML示例

点我查看完整的Demo示例

<com.hjq.bar.TitleBar
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:title="默认的标题栏" />

设置监听事件

mTitleBar.setOnTitleBarListener(new OnTitleBarListener() {

    @Override
    public void onLeftClick(View view) {
        ToastUtils.show("左项View被点击");
    }

    @Override
    public void onTitleClick(View view) {
        ToastUtils.show("中间View被点击");
    }

    @Override
    public void onRightClick(View view) {
        ToastUtils.show("右项View被点击");
    }
});

统一 TitleBar 样式

如果对 TitleBar 的默认样式或者属性不满意,可以在 Application 初始化的地方进行拦截并修改

public class XXApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        // 初始化 TitleBar
        TitleBar.setDefaultInitializer(new LightBarInitializer() {

            @Override
            protected TextView createTextView(Context context) {
                return new AppCompatTextView(context);
            }

            @Override
            public TextView getLeftView(Context context) {
                return super.getLeftView(context);
            }

            @Override
            public TextView getTitleView(Context context) {
                return super.getTitleView(context);
            }

            @Override
            public TextView getRightView(Context context) {
                return super.getRightView(context);
            }

            @Override
            public View getLineView(Context context) {
                return super.getLineView(context);
            }

            @Override
            public Drawable getBackgroundDrawable(Context context) {
                return super.getBackgroundDrawable(context);
            }

            @Override
            public Drawable getBackIcon(Context context) {
                return super.getBackIcon(context);
            }

            @Override
            public int getHorizontalPadding(Context context) {
                return super.getHorizontalPadding(context);
            }

            @Override
            public int getVerticalPadding(Context context) {
                return super.getVerticalPadding(context);
            }
        });
    }
}

框架亮点

  • 性能最佳:不使用 LayoutInflater,而使用代码创建 View 的形式

  • 体验最优:TitleBar 默认样式效果已经非常好,可下载 Demo 测试

  • 支持操控子控件:可以在代码中获取 TitleBar 的子控件进行调用相关的 API

  • 兼容沉浸式状态栏:兼容 Github 的沉浸式状态栏框架,达到完全沉浸的效果

  • 框架兼容性良好:本框架不依赖任何第三方库,支持兼容所有的安卓版本

  • 支持全局配置样式:可以在 Application 中初始化 TitleBar 样式,达到一劳永逸的效果

作者的其他开源项目

微信公众号:Android轮子哥

Android 技术分享 QQ 群:78797078

如果您觉得我的开源库帮你节省了大量的开发时间,请扫描下方的二维码随意打赏,要是能打赏个 10.24 🐵就太👍了。您的支持将鼓励我继续创作

点击查看捐赠列表

License

Copyright 2018 Huang JinQun

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.
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].