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

Issues 1 question #94

Merged
merged 2 commits into from
Jun 1, 2017
Merged
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
8 changes: 8 additions & 0 deletions app/src/main/java/devlight/io/sample/VerticalNtbActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public Object instantiateItem(final ViewGroup container, final int position) {
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_first),
Color.parseColor(colors[0]))
.title("ic_first")
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.build()
);
Expand All @@ -73,48 +74,55 @@ public Object instantiateItem(final ViewGroup container, final int position) {
getResources().getDrawable(R.drawable.ic_second),
Color.parseColor(colors[1]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.title("ic_second")
.build()
);
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_third),
Color.parseColor(colors[2]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.title("ic_third")
.build()
);
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_fourth),
Color.parseColor(colors[3]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.title("ic_fourth")
.build()
);
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_fifth),
Color.parseColor(colors[4]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.title("ic_fifth")
.build()
);
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_sixth),
Color.parseColor(colors[5]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.title("ic_sixth")
.build()
);
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_seventh),
Color.parseColor(colors[6]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.title("ic_seventh")
.build()
);
models.add(
new NavigationTabBar.Model.Builder(
getResources().getDrawable(R.drawable.ic_eighth),
Color.parseColor(colors[7]))
.selectedIcon(getResources().getDrawable(R.drawable.ic_eighth))
.title("ic_eighth")
.build()
);

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/layout/activity_vertical_ntb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
android:background="#423752">

<devlight.io.library.ntb.NavigationTabBar
app:ntb_title_mode="all"
app:ntb_titled="true"
app:ntb_title_size="14sp"
android:id="@+id/ntb_vertical"
android:layout_width="50dp"
android:layout_height="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,13 +1002,19 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
mBehaviorEnabled = false;
// Disable other features
mIsHorizontalOrientation = false;
mIsTitled = false;
// mIsTitled = false;
mIsBadged = false;

mModelSize = (float) height / (float) mModels.size();
mIconSize = (int) ((mModelSize > width ? width : mModelSize) *
// Get smaller side
float side = mModelSize > width ? width : mModelSize;

mIconSize = (int) (side *
(mIconSizeFraction == AUTO_SCALE ?
DEFAULT_ICON_SIZE_FRACTION : mIconSizeFraction));

if (mModelTitleSize == AUTO_SIZE) mModelTitleSize = side * TITLE_SIZE_FRACTION;
mTitleMargin = side * TITLE_MARGIN_FRACTION;
}

// Set bounds for NTB
Expand Down Expand Up @@ -1162,16 +1168,24 @@ protected void onDraw(final Canvas canvas) {
final float matrixCenterY;

// Set offset to titles
final float leftTitleOffset = (mModelSize * i) + (mModelSize * 0.5F);
final float topTitleOffset =
mBounds.height() - (mBounds.height() - iconMarginTitleHeight) * 0.5F;

final float leftTitleOffset;
final float topTitleOffset;
if (mIsHorizontalOrientation) {
leftOffset = (mModelSize * i) + (mModelSize - model.mIcon.getWidth()) * 0.5F;
topOffset = (mBounds.height() - model.mIcon.getHeight()) * 0.5F;

// Set offset to titles
leftTitleOffset = (mModelSize * i) + (mModelSize * 0.5F);
topTitleOffset =
mBounds.height() - (mBounds.height() - iconMarginTitleHeight) * 0.5F;

} else {
leftOffset = (mBounds.width() - (float) model.mIcon.getWidth()) * 0.5F;
topOffset = (mModelSize * i) + (mModelSize - (float) model.mIcon.getHeight()) * 0.5F;

// Set offset to titles
leftTitleOffset = leftOffset + (float) model.mIcon.getWidth() * 0.5F;
topTitleOffset = topOffset + (model.mIcon.getHeight() + iconMarginTitleHeight) * 0.5f;
}

matrixCenterX = leftOffset + (float) model.mIcon.getWidth() * 0.5F;
Expand Down