diff --git a/app/src/main/res/font/cairo.ttf b/app/src/main/res/font/cairo.ttf new file mode 100644 index 0000000..7be096b Binary files /dev/null and b/app/src/main/res/font/cairo.ttf differ diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index b5bf68e..e67ce9e 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -14,66 +14,67 @@ android:id="@+id/swipeBtnDisabled" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginEnd="20dp" android:layout_marginStart="20dp" + android:layout_marginEnd="20dp" android:layout_marginBottom="20dp" + app:button_background="@drawable/shape_button" + app:button_bottom_padding="18dp" app:button_image_disabled="@drawable/ic_lock_open_black_24dp" app:button_image_enabled="@drawable/ic_lock_outline_black_24dp" - app:button_background="@drawable/shape_button" app:button_image_height="60dp" app:button_image_width="100dp" - app:button_bottom_padding="18dp" app:button_left_padding="38dp" app:button_right_padding="38dp" app:button_top_padding="18dp" + app:font_family="@font/cairo" app:initial_state="disabled" app:inner_text="SWIPE" app:inner_text_background="@drawable/shape_rounded" + app:inner_text_bottom_padding="18dp" app:inner_text_color="@android:color/white" app:inner_text_size="16sp" - app:inner_text_top_padding="18dp" - app:inner_text_bottom_padding="18dp" /> + app:inner_text_top_padding="18dp" /> + app:inner_text_top_padding="18dp" /> - + + android:layout_marginTop="20dp" + android:fontFamily="@font/cairo" + android:text="TOGGLE" /> diff --git a/swipe-button/src/main/java/com/ebanx/swipebtn/SwipeButton.java b/swipe-button/src/main/java/com/ebanx/swipebtn/SwipeButton.java index d8f45b2..e3062b2 100644 --- a/swipe-button/src/main/java/com/ebanx/swipebtn/SwipeButton.java +++ b/swipe-button/src/main/java/com/ebanx/swipebtn/SwipeButton.java @@ -12,6 +12,7 @@ import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; +import android.support.v4.content.res.ResourcesCompat; import android.util.AttributeSet; import android.view.Gravity; import android.view.MotionEvent; @@ -204,6 +205,11 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr, int def centerText.setText(typedArray.getText(R.styleable.SwipeButton_inner_text)); centerText.setTextColor(typedArray.getColor(R.styleable.SwipeButton_inner_text_color, Color.WHITE)); + //Add font family to inner text + if (typedArray.hasValue(R.styleable.SwipeButton_font_family)) { + int fontId = typedArray.getResourceId(R.styleable.SwipeButton_font_family, -1); + centerText.setTypeface(ResourcesCompat.getFont(context, fontId)); + } float textSize = DimentionUtils.converPixelsToSp( typedArray.getDimension(R.styleable.SwipeButton_inner_text_size, 0), context); @@ -403,7 +409,7 @@ public void onAnimationUpdate(ValueAnimator animation) { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); - if (layer!=null) { + if (layer != null) { layer.setVisibility(View.GONE); } } @@ -449,7 +455,7 @@ public void onAnimationEnd(Animator animation) { if (onStateChangeListener != null) { onStateChangeListener.onStateChange(active); } - if (layer!=null) { + if (layer != null) { layer.setVisibility(View.GONE); } } diff --git a/swipe-button/src/main/res/values/attrs.xml b/swipe-button/src/main/res/values/attrs.xml index ecd20f7..7e9d179 100644 --- a/swipe-button/src/main/res/values/attrs.xml +++ b/swipe-button/src/main/res/values/attrs.xml @@ -25,7 +25,7 @@ - + \ No newline at end of file