diff --git a/library/src/main/java/uk/co/deanwild/materialshowcaseview/MaterialShowcaseSequence.java b/library/src/main/java/uk/co/deanwild/materialshowcaseview/MaterialShowcaseSequence.java index afa898ef..767d942b 100644 --- a/library/src/main/java/uk/co/deanwild/materialshowcaseview/MaterialShowcaseSequence.java +++ b/library/src/main/java/uk/co/deanwild/materialshowcaseview/MaterialShowcaseSequence.java @@ -59,6 +59,9 @@ public MaterialShowcaseSequence addSequenceItem(MaterialShowcaseView sequenceIte } mShowcaseQueue.add(sequenceItem); + if (mConfig != null) { + sequenceItem.setConfig(mConfig); + } return this; } diff --git a/library/src/main/java/uk/co/deanwild/materialshowcaseview/MaterialShowcaseView.java b/library/src/main/java/uk/co/deanwild/materialshowcaseview/MaterialShowcaseView.java index a8761645..b009f6d4 100644 --- a/library/src/main/java/uk/co/deanwild/materialshowcaseview/MaterialShowcaseView.java +++ b/library/src/main/java/uk/co/deanwild/materialshowcaseview/MaterialShowcaseView.java @@ -23,6 +23,7 @@ import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.FrameLayout; +import android.widget.LinearLayout; import android.widget.TextView; import java.util.ArrayList; @@ -492,6 +493,26 @@ private void setDismissTextColor(int textColour) { } } + private void setDismissTextGravity(int dismissTextGravity){ + if (mDismissButton != null) { + LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.mDismissButton.getLayoutParams(); + layoutParams.gravity = dismissTextGravity; + this.mDismissButton.setLayoutParams(layoutParams); + } + } + + private void setContentTextGravity(int contentTextGravity){ + if(mContentTextView != null ) { + this.mContentTextView.setGravity(contentTextGravity); + } + } + + private void setTitleTextGravity(int titleTextGravity){ + if(mTitleTextView != null ) { + this.mTitleTextView.setGravity(titleTextGravity); + } + } + private void setShapePadding(int padding) { mShapePadding = padding; } @@ -749,6 +770,22 @@ public Builder setTitleText(CharSequence text) { } + private Builder setDismissTextGravity(int dismissTextGravity){ + showcaseView.setDismissTextGravity(dismissTextGravity); + return this ; + } + + private Builder setContentTextGravity(int mGravity){ + showcaseView.setContentTextGravity(mGravity); + return this ; + } + + private Builder setTitleTextGravity(int mGravity){ + showcaseView.setTitleTextGravity(mGravity); + return this ; + } + + /** * Tooltip mode config options * diff --git a/library/src/main/java/uk/co/deanwild/materialshowcaseview/ShowcaseConfig.java b/library/src/main/java/uk/co/deanwild/materialshowcaseview/ShowcaseConfig.java index 33d1458f..a5974fa1 100644 --- a/library/src/main/java/uk/co/deanwild/materialshowcaseview/ShowcaseConfig.java +++ b/library/src/main/java/uk/co/deanwild/materialshowcaseview/ShowcaseConfig.java @@ -1,8 +1,11 @@ package uk.co.deanwild.materialshowcaseview; import android.graphics.Color; + +import android.view.Gravity; import android.graphics.Typeface; + import uk.co.deanwild.materialshowcaseview.shape.CircleShape; import uk.co.deanwild.materialshowcaseview.shape.Shape; @@ -10,6 +13,11 @@ public class ShowcaseConfig { public static final String DEFAULT_MASK_COLOUR = "#dd335075"; + public static final long DEFAULT_FADE_TIME = 300; + public static final long DEFAULT_DELAY = 0; + public static final Shape DEFAULT_SHAPE = new CircleShape(); + public static final int DEFAULT_SHAPE_PADDING = 10; + public static final int DEFAULT_TEXT_GRAVITY = Gravity.LEFT; private long mDelay = -1; private int mMaskColour; @@ -17,6 +25,9 @@ public class ShowcaseConfig { private int mContentTextColor; private int mDismissTextColor; + private int dismissTextGravity = DEFAULT_TEXT_GRAVITY ; + private int titleTextGravity = DEFAULT_TEXT_GRAVITY ; + private int contentTextGravity = DEFAULT_TEXT_GRAVITY ; private long mFadeDuration = -1; private Shape mShape = null; private int mShapePadding = -1; @@ -99,4 +110,28 @@ public Boolean getRenderOverNavigationBar() { public void setRenderOverNavigationBar(boolean renderOverNav) { this.renderOverNav = renderOverNav; } + + public void setDismissTextGravity(int dismissTextGravity) { + this.dismissTextGravity = dismissTextGravity; + } + + public void setTitleTextGravity(int titleTextGravity) { + this.titleTextGravity = titleTextGravity; + } + + public void setContentTextGravity(int contentTextGravity) { + this.contentTextGravity = contentTextGravity; + } + + public int getDismissTextGravity() { + return dismissTextGravity; + } + + public int getTitleTextGravity() { + return titleTextGravity; + } + + public int getContentTextGravity() { + return contentTextGravity; + } } diff --git a/sample/src/main/java/uk/co/deanwild/materialshowcaseviewsample/SequenceExample.java b/sample/src/main/java/uk/co/deanwild/materialshowcaseviewsample/SequenceExample.java index d2297dfe..bd5f3783 100644 --- a/sample/src/main/java/uk/co/deanwild/materialshowcaseviewsample/SequenceExample.java +++ b/sample/src/main/java/uk/co/deanwild/materialshowcaseviewsample/SequenceExample.java @@ -60,7 +60,10 @@ private void presentShowcaseSequence() { ShowcaseConfig config = new ShowcaseConfig(); config.setDelay(500); // half second between each showcase view - + config.setTitleTextGravity(Gravity.CENTER); + config.setDismissTextGravity(Gravity.CENTER); + config.setContentTextGravity(Gravity.CENTER); + MaterialShowcaseSequence sequence = new MaterialShowcaseSequence(this, SHOWCASE_ID); sequence.setOnItemShownListener(new MaterialShowcaseSequence.OnSequenceItemShownListener() {