Giter Site home page Giter Site logo

bottombarlayout's People

Contributors

chaychan avatar chnyangjie avatar liyujiang-gzu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bottombarlayout's Issues

设置图片大小后报错

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);
}

建议新增换肤支持

虽然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+"。该属性不能生效

IndexOutOfBoundsException 索引越界

错误日志
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

请问要怎么处理

小建议

项目确实不错,这样一来底部导航可以很方便的实现,使用过程发现一点小建议,给一下,同时也方便大家了。
1.依赖。作者写的貌似有点问题,建议还是用 implementation关键字或者api关键字吧,而不是compile
2.最小sdk。这个包有最小SDK要求minSdk的版本必须是16.
3.当然了,能写出这样的项目还是不错的,继续努力!

出现了两个标签都选中的状态

你好,看了你写的BottomBarLayout很赞,我发现了你的Demo中在第一个标签页还没有刷新完成的状态下点击其他标签页,虽然刷新动画停止了,但是经过3s过后,第一个标签还是会处于选中状态,此时,点击后三个标签,第一个标签的选中状态也还是不会取消。

动态添加item

如何动态添加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) {
//重复选中
}
});
个人认为监听方式改为这样是最好的,希望采纳

问题非常大,java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

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,相应的导航图标也应该是选中第三个

关于底部栏图片的大小

应该要添加设置图片的大小,并且整个容器最好有个 padding

default

可以看到没有 padding 会显得比较挤,而且图片稍微有点大

怎么动态切换按钮

大佬,底部导航默认选中第一个按钮,当我点击其他按钮时跳出一个activity登录页面,当登录成功关闭登录页面后显示的是我点击后的页面,我想让登录后再重新回到默认第一页面按钮状态也是第一个选中,现在的问题是我只能设置页面显示第一个,底部导航按钮还是显示选中的其他按钮,而不是第一个按钮BottomBarItem hombottomItem = mBottomBarLayout.getBottomItem(0);
hombottomItem.setSelectedIcon(R.mipmap.home_select); 设置第一个按钮的状态也没用

清单文件冲突

<application android:allowBackup="true"
             android:label="@string/app_name"
             android:supportsRtl="true"
>

这是你library的清单文件,冲突了 ,能去掉吗

有内存泄漏的问题

这个库本身写的非常贴心,属性都很全,但是用到我的项目里超过2个Fragment就报内存泄漏的问题,我换回TabLayout就正常了,好可惜

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.