Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_three_tabs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
app:bb_behavior="motionless"
app:bb_tabXmlResource="@xml/bottombar_tabs_three" />

</RelativeLayout>
11 changes: 9 additions & 2 deletions bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class BottomBar extends LinearLayout implements View.OnClickListener, Vie
private static final int BEHAVIOR_SHY = 2;
private static final int BEHAVIOR_DRAW_UNDER_NAV = 4;
private static final int BEHAVIOR_ICONS_ONLY = 8;
private static final int BEHAVIOR_MOTIONLESS = 16;

private BatchTabPropertyApplier batchPropertyApplier;
private int primaryColor;
Expand Down Expand Up @@ -239,6 +240,10 @@ private boolean isIconsOnlyMode() {
return !isTabletMode && hasBehavior(BEHAVIOR_ICONS_ONLY);
}

private boolean isMotionlessMode() {
return !isTabletMode && hasBehavior(BEHAVIOR_MOTIONLESS);
}

private boolean hasBehavior(int behavior) {
return (behaviors | behavior) == behaviors;
}
Expand Down Expand Up @@ -337,6 +342,8 @@ private void updateItems(final List<BottomBarTab> bottomBarItems) {

if (isShiftingMode()) {
type = BottomBarTab.Type.SHIFTING;
} else if (isMotionlessMode()) {
type = BottomBarTab.Type.MOTIONLESS;
} else if (isTabletMode) {
type = BottomBarTab.Type.TABLET;
} else {
Expand Down Expand Up @@ -918,8 +925,8 @@ private void handleClick(BottomBarTab newTab) {
return;
}

oldTab.deselect(true);
newTab.select(true);
oldTab.deselect(!isMotionlessMode());
newTab.select(!isMotionlessMode());

shiftingMagic(oldTab, newTab, true);
handleBackgroundColorChange(newTab, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ void prepareLayout() {
int getLayoutResource() {
int layoutResource;
switch (type) {
case MOTIONLESS:
case FIXED:
layoutResource = R.layout.bb_bottom_bar_item_fixed;
break;
Expand Down Expand Up @@ -384,13 +385,16 @@ public Typeface getTitleTypeFace() {
void select(boolean animate) {
isActive = true;

boolean isMotionless = type == Type.MOTIONLESS;
int iconPaddingTop = isMotionless ? eightDps : sixDps;

if (animate) {
animateIcon(activeAlpha, ACTIVE_SHIFTING_TITLELESS_ICON_SCALE);
animateTitle(sixDps, ACTIVE_TITLE_SCALE, activeAlpha);
animateColors(inActiveColor, activeColor);
} else {
setTitleScale(ACTIVE_TITLE_SCALE);
setTopPadding(sixDps);
setTopPadding(iconPaddingTop);
setIconScale(ACTIVE_SHIFTING_TITLELESS_ICON_SCALE);
setColors(activeColor);
setAlphas(activeAlpha);
Expand All @@ -407,9 +411,10 @@ void deselect(boolean animate) {
isActive = false;

boolean isShifting = type == Type.SHIFTING;
boolean isMotionless = type == Type.MOTIONLESS;

float titleScale = isShifting ? 0 : INACTIVE_FIXED_TITLE_SCALE;
int iconPaddingTop = isShifting ? sixteenDps : eightDps;
float titleScale = isMotionless ? ACTIVE_TITLE_SCALE: isShifting ? 0 : INACTIVE_FIXED_TITLE_SCALE;
int iconPaddingTop = isMotionless ? eightDps : isShifting ? sixteenDps : eightDps;

if (animate) {
animateTitle(iconPaddingTop, titleScale, inActiveAlpha);
Expand Down Expand Up @@ -637,7 +642,7 @@ void restoreState(Bundle savedInstanceState) {
}

enum Type {
FIXED, SHIFTING, TABLET
MOTIONLESS, FIXED, SHIFTING, TABLET
}

public static class Config {
Expand Down
1 change: 1 addition & 0 deletions bottom-bar/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<flag name="shy" value="2" />
<flag name="underNavbar" value="4" />
<flag name="iconsOnly" value="8" />
<flag name="motionless" value="16" />
</attr>
<attr name="bb_longPressHintsEnabled" format="boolean" />
<attr name="bb_inActiveTabAlpha" format="float" />
Expand Down