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

Issue #212: Add possibility to configure alpha of description text. #213

Merged
merged 2 commits into from
Oct 12, 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
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class TapTarget {
boolean cancelable = true;
boolean tintTarget = true;
boolean transparentTarget = false;
float descriptionTextAlpha = 0.54f;

/**
* Return a tap target for the overflow button from the given toolbar
Expand Down Expand Up @@ -330,6 +331,15 @@ public TapTarget titleTextDimen(@DimenRes int dimen) {
return this;
}

/** Specify the alpha value [0.0, 1.0] of the description text **/
public TapTarget descriptionTextAlpha(float descriptionTextAlpha) {
if (descriptionTextAlpha < 0 || descriptionTextAlpha > 1f) {
throw new IllegalArgumentException("Given an invalid alpha value: " + descriptionTextAlpha);
}
this.descriptionTextAlpha = descriptionTextAlpha;
return this;
}

/**
* Specify the text size for the description via a dimen resource
* <p>
Expand Down Expand Up @@ -414,7 +424,6 @@ public TapTarget targetRadius(int targetRadius) {
return this;
}


/** Return the id associated with this tap target **/
public int id() {
return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ protected void onDraw(Canvas c) {

if (descriptionLayout != null && titleLayout != null) {
c.translate(0, titleLayout.getHeight() + TEXT_SPACING);
descriptionPaint.setAlpha((int) (0.54f * textAlpha));
descriptionPaint.setAlpha((int) (target.descriptionTextAlpha * textAlpha));
descriptionLayout.draw(c);
}
}
Expand Down