chaychan / bottombarlayout Goto Github PK
View Code? Open in Web Editor NEW(一个轻量级的底部导航控件)A simple and lightly widget to accomplish bottom Navigation,可设置未读数、提示点、提示消息
(一个轻量级的底部导航控件)A simple and lightly widget to accomplish bottom Navigation,可设置未读数、提示点、提示消息
Caused by: java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams
at com.chaychan.library.BottomBarItem.init(BottomBarItem.java:128)
at com.chaychan.library.BottomBarItem.(BottomBarItem.java:88)
at com.chaychan.library.BottomBarItem.(BottomBarItem.java:54)
将
if (mIconWidth != 0 && mIconHeight != 0){
//如果有设置图标的宽度和高度,则设置ImageView的宽高
LayoutParams imageLayoutParams = (LayoutParams) mImageView.getLayoutParams();
imageLayoutParams.width = mIconWidth;
imageLayoutParams.height = mIconHeight;
mImageView.setLayoutParams(imageLayoutParams);
}
修改为可解决:
if (mIconWidth != 0 && mIconHeight != 0){
//如果有设置图标的宽度和高度,则设置ImageView的宽高
FrameLayout.LayoutParams imageLayoutParams = (FrameLayout.LayoutParams) mImageView.getLayoutParams();
imageLayoutParams.width = mIconWidth;
imageLayoutParams.height = mIconHeight;
mImageView.setLayoutParams(imageLayoutParams);
}
万分感谢。
tab切换的时候可以不刷新吗?
或者另辟蹊径的方法
虽然bottombarlayout暴露了item,item暴露了imageview,但是依然不能很好的实现换肤,根本原因在于代码只考虑了xml配置的情况,强制使用resId。建议修改item代码,允许动态设置图标drawable(非resId,换肤通常是sd卡加载),最好只保留drawable\,删除resid,在初始化的时候将xml中配置的resid转化为drawable,提高通用性和灵活性
版本:1.2.1
集成方式:module
minSdkVersion:16
compileSdkVersion:28
buildToolsVersion:"28.0.3"
gradle:3.4.1
问题描述:设置了mBottomBarLayout.setSmoothScroll(true),并且在xml中也设置了app:smoothScroll="true",tab无法使用滑动的方式切换,也没有gif中的动画效果
smoothScroll 设置false 、 mBottomBarLayout.setSmoothScroll(false); 都无法禁止掉项目的fragment 左右滑动切换
五个图标想要中间的突出于导航栏
设置未读数阈值
未读数的阈值可以指定BottomBarItem的unreadThreshold属性设置,默认该值为99,如设置 app:unreadThreshold="999" , 若未读数超过该值,则显示"999+"。该属性不能生效
Error:(42, 13) Failed to resolve: com.github.chaychan:BottomBarLayout:1.0.9
Show in File
Show in Project Structure dialog
中间突起的大按钮有吗
如何禁止每次切换tab 刷新问题?
错误日志
java.util.ArrayList.get(ArrayList.java:437)
com.chaychan.library.BottomBarLayout.onRestoreInstanceState(BottomBarLayout.java:272)
android.view.View.dispatchRestoreInstanceState(View.java:18814)
相关代码
protected void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
Bundle bundle = (Bundle)state;
this.mCurrentItem = bundle.getInt("state_item");
this.resetState();
((BottomBarItem)this.mItemViews.get(this.mCurrentItem)).setStatus(true);
super.onRestoreInstanceState(bundle.getParcelable("instance_state"));
} else {
super.onRestoreInstanceState(state);
}
}
mItemViews 这里 index---0 ; size --- 0
请问要怎么处理
或者降到api15也成,4.0.3有的项目还是要求兼容到
项目确实不错,这样一来底部导航可以很方便的实现,使用过程发现一点小建议,给一下,同时也方便大家了。
1.依赖。作者写的貌似有点问题,建议还是用 implementation关键字或者api关键字吧,而不是compile
2.最小sdk。这个包有最小SDK要求minSdk的版本必须是16.
3.当然了,能写出这样的项目还是不错的,继续努力!
你好,看了你写的BottomBarLayout很赞,我发现了你的Demo中在第一个标签页还没有刷新完成的状态下点击其他标签页,虽然刷新动画停止了,但是经过3s过后,第一个标签还是会处于选中状态,此时,点击后三个标签,第一个标签的选中状态也还是不会取消。
如何动态添加BottomBarItem?很多属性只能在xml设置
mBottomBar.setOnTabSelectedListener(new BottomBar.OnTabSelectedListener()
{
@OverRide
public void onTabSelected(int position, int prePosition) {
//选中
}
@OverRide
public void onTabUnselected(int position) {
//未选中
}
@OverRide
public void onTabReselected(int position) {
//重复选中
}
});
个人认为监听方式改为这样是最好的,希望采纳
如题
RT,条目点击事件无法响应
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.get(ArrayList.java:437)
at com.chaychan.library.BottomBarLayout.onRestoreInstanceState(BottomBarLayout.java:272)
at android.view.View.dispatchRestoreInstanceState(View.java:20929)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:4019)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:4025)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:4025)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:4025)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:4025)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:4025)
at android.view.View.restoreHierarchyState(View.java:20907)
at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2185)
at android.app.Activity.onRestoreInstanceState(Activity.java:1721)
作者您好,首先,非常感谢您的付出并开源了这个轻量级的控件。我下载了源码,仔细的查看过,并结合业务需求提几点意见。
1.首先,BottomLayout 和BottomItem都是继承自线性布局,同时目前只支持xml方式配置使用,这里有一个问题,如果我需要将一个Activity进行封装,动态配置fragment,和底部按钮,就无法实现。
2.现在的使用方式,是必须强行调用setViewPager方法,也就是说,此空间跟viewpager有很强的耦合性。
那么,如果我的需求是,不需要使用viewpager 想通过hideshow的方式 使用,这个控件又不允许了。
3.针对点击回调,应该抽象出onItemReSelected()方法,单独处理,二不要在onItemSelected里边通过currentitem和position是否相等来做判断,
针对以上3个问题我已经修改了代码。欢迎交流
有没有修改默认选择底部导航图标的方法,比如打开后默认展示的是第三个fragment,相应的导航图标也应该是选中第三个
拉不下来
提个新需求,这也是市面上应用比较多的,底部导航栏中让个别模块的图标呈现凸起状态。
大佬,首先感谢你的库,很好用。
有时候消息太多想一键拖掉消息,类似QQ那样,可以实现吗?
java.lang.ClassNotFoundException: com.airbnb.lottie.LottieAnimationView
大佬,底部导航默认选中第一个按钮,当我点击其他按钮时跳出一个activity登录页面,当登录成功关闭登录页面后显示的是我点击后的页面,我想让登录后再重新回到默认第一页面按钮状态也是第一个选中,现在的问题是我只能设置页面显示第一个,底部导航按钮还是显示选中的其他按钮,而不是第一个按钮BottomBarItem hombottomItem = mBottomBarLayout.getBottomItem(0);
hombottomItem.setSelectedIcon(R.mipmap.home_select); 设置第一个按钮的状态也没用
长按背景会闪两三下
设置滑动后,ViewPager滑动了,BottomBarItem 没有切换
<application android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
>
这是你library的清单文件,冲突了 ,能去掉吗
不知道为什么修改background无法修改颜色
这个库本身写的非常贴心,属性都很全,但是用到我的项目里超过2个Fragment就报内存泄漏的问题,我换回TabLayout就正常了,好可惜
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.