Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added titleTextColor attribute to have custom title text color #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,14 @@ This view can be used independently for:
| **attr** | **Description** |
| ------------- | ------------- |
| bt_active | Sets to Active State |
| bt_colorActive | When in Active State, uses this color for the Icon and Title |
| bt_colorInctive | When in Inactive State, uses this color for the Icon and Title |
| bt_colorActive | When in Active State, uses this color for the Icon and set this as default Title text color |
| bt_colorInActive | When in Inactive State, uses this color for the Icon and Title |
| bt_icon | Sets the Icon Drawable |
| bt_iconWidth | Updates the Icon Width|
| bt_iconHeigth | Updates the Icon Height |
| bt_title | Sets the Title Text |
| bt_titleSize | Updates the Tilte Text Size in sp |
| bt_titleColorActive | You can set specific color for your title text |
| bt_titleSize | Updates the Title Text Size in sp |
| bt_shape | Sets the Background Drawable. Use **TransitionDrawable** to get fade in-out effect when toggling |
| bt_showShapeAlways | If true and using Normal drawable, background shape remains visible always |
| bt_shapeColor | Changes the tint color of the shape. N/A when using TransitionDrawable or showShapeAlways is true. |
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/layout/fragment_equal_bottom_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
app:bt_titleColorActive="@color/red_active"
app:bt_colorActive="@color/blue_active"
app:bt_colorInactive="@color/default_inactive"
app:bt_icon="@drawable/ic_shop"
Expand All @@ -48,6 +49,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
app:bt_titleColorActive="@color/green_active"
app:bt_colorActive="@color/purple_active"
app:bt_colorInactive="@color/default_inactive"
app:bt_icon="@drawable/ic_photos"
Expand All @@ -59,6 +61,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
app:bt_titleColorActive="@color/blue_active"
app:bt_colorActive="@color/green_active"
app:bt_colorInactive="@color/default_inactive"
app:bt_icon="@drawable/ic_call"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class BubbleToggleItem {
private String title = "";

private int colorActive = Color.BLUE;
private int titleColorActive = colorActive;
private int colorInactive = Color.BLACK;
private int shapeColor = Integer.MIN_VALUE;

Expand Down Expand Up @@ -72,6 +73,14 @@ void setTitle(String title) {
this.title = title;
}

int getTitleColorActive() {
return titleColorActive;
}

void setTitleColorActive(int titleColorActive) {
this.titleColorActive = titleColorActive;
}

int getColorActive() {
return colorActive;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import android.os.Build;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.content.res.AppCompatResources;
Expand All @@ -34,6 +33,7 @@
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gauravk.bubblenavigation.util.ViewUtils;

/**
Expand Down Expand Up @@ -101,6 +101,7 @@ private void init(Context context, @Nullable AttributeSet attrs) {
Drawable shape = null;
int shapeColor = Integer.MIN_VALUE;
int colorActive = ViewUtils.getThemeAccentColor(context);
int titleColorActive = colorActive;
int colorInactive = ContextCompat.getColor(context, R.color.default_inactive_color);
float titleSize = context.getResources().getDimension(R.dimen.default_nav_item_text_size);
maxTitleWidth = context.getResources().getDimension(R.dimen.default_nav_item_title_max_width);
Expand Down Expand Up @@ -129,6 +130,7 @@ private void init(Context context, @Nullable AttributeSet attrs) {
title = ta.getString(R.styleable.BubbleToggleView_bt_title);
titleSize = ta.getDimension(R.styleable.BubbleToggleView_bt_titleSize, titleSize);
colorActive = ta.getColor(R.styleable.BubbleToggleView_bt_colorActive, colorActive);
titleColorActive = ta.getColor(R.styleable.BubbleToggleView_bt_titleColorActive, colorActive);
colorInactive = ta.getColor(R.styleable.BubbleToggleView_bt_colorInactive, colorInactive);
isActive = ta.getBoolean(R.styleable.BubbleToggleView_bt_active, false);
animationDuration = ta.getInteger(R.styleable.BubbleToggleView_bt_duration, DEFAULT_ANIM_DURATION);
Expand Down Expand Up @@ -160,6 +162,7 @@ private void init(Context context, @Nullable AttributeSet attrs) {
bubbleToggleItem.setTitlePadding(titlePadding);
bubbleToggleItem.setShapeColor(shapeColor);
bubbleToggleItem.setColorActive(colorActive);
bubbleToggleItem.setTitleColorActive(titleColorActive);
bubbleToggleItem.setColorInactive(colorInactive);
bubbleToggleItem.setIconWidth(iconWidth);
bubbleToggleItem.setIconHeight(iconHeight);
Expand Down Expand Up @@ -219,7 +222,7 @@ private void createBubbleItemView(Context context) {
lpTitle.addRule(RelativeLayout.RIGHT_OF, iconView.getId());
titleView.setLayoutParams(lpTitle);
titleView.setSingleLine(true);
titleView.setTextColor(bubbleToggleItem.getColorActive());
titleView.setTextColor(bubbleToggleItem.getTitleColorActive());
titleView.setText(bubbleToggleItem.getTitle());
titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, bubbleToggleItem.getTitleSize());
//get the current measured title width
Expand Down
1 change: 1 addition & 0 deletions bubblenavigation/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<attr name="bt_title" format="string" />
<attr name="bt_titleSize" format="dimension" />
<attr name="bt_colorActive" format="color" />
<attr name="bt_titleColorActive" format="color" />
<attr name="bt_colorInactive" format="color" />
<attr name="bt_active" format="boolean" />
<attr name="bt_duration" format="integer" />
Expand Down
Binary file removed sample/bn_four.gif
Binary file not shown.
Binary file removed sample/bn_one.gif
Binary file not shown.
Binary file removed sample/bn_three.gif
Binary file not shown.
Binary file removed sample/bn_two.gif
Binary file not shown.
Binary file removed sample/sample_bottom.gif
Binary file not shown.
Binary file removed sample/sample_middle.gif
Binary file not shown.
Binary file removed sample/sample_top.gif
Binary file not shown.