Skip to content

Commit

Permalink
Issue #212: Add possibility to configure alpha of description text. (#…
Browse files Browse the repository at this point in the history
…213)

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

* Add possibility to configure alpha of description text.
  • Loading branch information
leshchenko authored and xiphirx committed Oct 12, 2017
1 parent 42284f9 commit b812385
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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

0 comments on commit b812385

Please sign in to comment.