我是一名热爱 Android 技术的程序员,平时爱造轮子,人送外号轮子哥 。
我的理想是让这个世界没有难开发的安卓项目,消灭一切难维护的代码。
Android 标题栏框架,从此布局属性不用记
License: Apache License 2.0
最近发现有很多人给我提 issue 没有认真按照模板上面的来填写,导致了在排查问题的过程中浪费了作者许多不必要的时间和精力,所以请后面提 issue 的人务必严格遵守,否则我不会受理,直接关闭 issue。
左边返回按钮绝大多数情况下的功能是返回(个人认为),所以建议加上销毁activity事件,能减少很多Activit中的重复代码
你好!请问能不能再丰富一下效果,就是标题栏右边图标,有时候ui设计是可以同时放两个可点击的icon的。对于这种情况,是否可以继续完善支持一下。
非常感谢!
做夜间模式功能的时候,titlebar的下方有一条白边做夜间模式功能的时候,titlebar的下方有一条白边做夜间模式功能的时候,titlebar的下方有一条白边
hi,mTitleBar.getRightView().setVisibility(View.VISIBLE); 获取左右视图,然后设置text或者设置显示与隐藏无效。
你好, 升级后 依然存在title偶尔跳动得问题,
我是用的沉浸式状态栏三方是 https://github.com/gyf-dev/ImmersionBar
ImmersionBar.with(this).titleBar(view);//设置重叠问题
这里需要传入的view,TitleBar没有提供啊,怎么解决?
1.如何设置background ,TitleBar 有没有提供,还是用的系统的?
2.titleColor ,xml 中 和代码设置都不生效。
请问,有没有办法可以设置左边返回按钮的大小?
Github沟通效率实在是很低下,大家伙有问题或者Bug直接到Q群78797078私信给我反馈就OK,我会尽快答复你的问题
自定义配置如下:
class PetTitleBarStyle : CommonBarStyle() {
override fun createBackgroundDrawable(context: Context): Drawable =
ColorDrawable(context.getCol(R.color.white))
override fun createBackIcon(context: Context?): Drawable =
getDrawableResources(context, R.mipmap.ic_arrow_back_black)
override fun createTitleView(context: Context): TextView {
val titleTv = super.createTitleView(context)
titleTv.setTextColor(context.getCol(R.color.title_text))
titleTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 17f)
return titleTv
}
override fun createLeftView(context: Context): TextView {
val leftView = super.createLeftView(context)
leftView.setTextColor(context.getCol(R.color.white))
setViewBackground(
leftView, SelectorDrawable.Builder()
.setDefault(ColorDrawable(context.getCol(R.color.white)))
.setFocused(ColorDrawable(context.getCol(R.color.white)))
.setPressed(ColorDrawable(context.getCol(R.color.white)))
.build()
)
return leftView
}
override fun createRightView(context: Context): TextView {
val rightView = super.createRightView(context)
rightView.setTextColor(context.getCol(R.color.title_text))
setViewBackground(
rightView, SelectorDrawable.Builder()
.setDefault(ColorDrawable(context.getCol(R.color.white)))
.setFocused(ColorDrawable(context.getCol(R.color.white)))
.setPressed(ColorDrawable(context.getCol(R.color.white)))
.build()
)
return rightView
}
override fun createLineView(context: Context): View {
val lineView = super.createLineView(context)
setViewBackground(lineView, ColorDrawable(context.getCol(R.color.divider_color)))
return lineView
}
}
案例使用androidx,并使用constraintlayout, 点击返回键,无反应。
如题。
有需求遇到:想设置标题栏文字的bold等样式,比如中间文字变大变粗。
中间及作用字体无法加粗
右边有多个button,怎么弄,要自定义布局吗
使用自定义图片,显示图片非常小
需求要webview的标题栏上,返回键旁边加一个叉号关闭按钮
样式为 【 left + title 】的时候(即没有设置右边的情况),第一次打开后title会从右边一点点跳到正中间,预览布局的时候title也是往右偏了一点的。每次都跳动很不好吧。谢谢大佬分享。
左面是图标文字 右面是图标,中间文字会往右偏移,每次页面跳转顶部都会从右面往中间跳,应该怎么解决?
项目引入三方字体库,titlebar无法适配。
试过重写createTitleView方法,直接设置textview的字体,也是无效。
希望大佬能早日适配更好,谢谢。
titleBar是一个箭头和文字,怎样调整箭头和文字之间的距离?
还有怎样去掉点击效果,或者统一点击效果,跟里面app一样的效果?
我在TitleBar里添加了3个子控件并设置了id, 但是无法触发点击事件。
是只有TitleBar里的leftview、rightview、titleview才能点击吗?
Theme.MaterialComponents.DayNight.NoActionBar
报错信息如下:
android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.hjq.bar.TitleBar
.technology.cheliang.storage.ui.activity.login.RegisterActivity}: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.hjq.bar.TitleBar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3303)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3411)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class com.hjq.bar.TitleBar
你好,现在有个需求是标题栏中间是图标,不设置文字,这个现在有方法吗?
需要在代码中改变titlebar的barstyle
框架版本:XXX
问题描述:XXX
复现步骤:XXX
是否必现:填是/否
手机信息:例如某米 9 / Android 10
是部分机型还是所有机型都会出现:部分/全部(例如:某为,某 Android 版本会出现)
框架最新的版本是否存在这个问题:是/否(如果用的是旧版本的话,建议升级看问题是否还存在)
是否已经查阅框架文档还未能解决的:是/否(文档会提供最常见的问题解答,可以看看是否有自己想要的)
issue 是否有人曾提过类似的问题:是/否(看看曾经有人提过类似的问题,先参考一下别人是怎么解决的)
是否可以通过 Demo 来复现该问题:是/否(排查一下是不是自己的项目代码写得有问题导致的)
使用原生 API 是否会出现该问题:是/否(排查一下是不是框架的代码写法存在问题导致的)
提供报错堆栈(如果有报错的话必填)
提供截图或视频(根据需要提供,此项不强制)
提供解决方案(如果已经解决了的话,此项不强制)
1、打比方,将高度设为 58dp,发现子 view 底部空了一部分,上下不会对称。
2、本库不错,感觉还可以应用于设置页面,不单单是标题,减少很多不必要的重复工作。
为此,希望能增加属性设置分割线边距,能实现像微信一样,分割线左边有边距,右边充满。
您好,是否能添加 左右titleIcon 上下的功能?
// 设置TitleBar默认的宽度
if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.AT_MOST
|| MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.UNSPECIFIED) {
widthMeasureSpec = MeasureSpec.makeMeasureSpec(widthMeasureSpec, MeasureSpec.EXACTLY);
}
这里为什么是获取的高的测量模式
如果想给 title 字体设置粗体 , 怎么做?
左边设置了一个返回图标和文字,右边一个文字,发现中间的文字距离左边和右边不对等,左边的往右挪了一点,想往做再挪一点就好了。
如题,建议在项目主页加几个gif效果图,让应用开发者看到,开发者方可知道此库有没有自己想要的效果
按钮距离左右间距不能设置吗
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.