diff --git a/library/src/main/java/com/chaychan/library/BottomBarItem.java b/library/src/main/java/com/chaychan/library/BottomBarItem.java index 4e0b16ba578f3988d080f58d3247f6fe3c17f871..7c544f1915a18ad7e2e458a62ae5e62c2b2b9bf5 100644 --- a/library/src/main/java/com/chaychan/library/BottomBarItem.java +++ b/library/src/main/java/com/chaychan/library/BottomBarItem.java @@ -171,7 +171,7 @@ public class BottomBarItem extends LinearLayout { } public void setStatus(boolean isSelected) { - mImageView.setImageResource(isSelected ? mIconSelectedResourceId : mIconNormalResourceId); + mImageView.setImageDrawable(getResources().getDrawable(isSelected ? mIconSelectedResourceId : mIconNormalResourceId)); mTextView.setTextColor(isSelected ? mTextColorSelected : mTextColorNormal); } diff --git a/library/src/main/java/com/chaychan/library/BottomBarLayout.java b/library/src/main/java/com/chaychan/library/BottomBarLayout.java index 3a93fc06580db91d26a8118228a2bcf382747c7a..2f4f0f98efb57c4ec54303d4fe3833c336c6afc3 100644 --- a/library/src/main/java/com/chaychan/library/BottomBarLayout.java +++ b/library/src/main/java/com/chaychan/library/BottomBarLayout.java @@ -119,11 +119,11 @@ public class BottomBarLayout extends LinearLayout implements ViewPager.OnPageCha } /** - * 重置所有按钮的状态 + * 重置当前按钮的状态 */ private void resetState() { - for (int i = 0; i < mChildCount; i++) { - mItemViews.get(i).setStatus(false); + if (mCurrentItem < mItemViews.size()){ + mItemViews.get(mCurrentItem).setStatus(false); } }