Skip to content
This repository has been archived by the owner on Mar 11, 2022. It is now read-only.

Added opportunity to enable or disable inner text word wrap #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -12,6 +12,7 @@
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
Expand Down Expand Up @@ -214,6 +215,12 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr, int def
centerText.setTextSize(12);
}

boolean textWrap = typedArray.getBoolean(R.styleable.SwipeButton_inner_text_wrap, false);
if (!textWrap) {
centerText.setMaxLines(1);
centerText.setEllipsize(TextUtils.TruncateAt.END);
}

disabledDrawable = typedArray.getDrawable(R.styleable.SwipeButton_button_image_disabled);
enabledDrawable = typedArray.getDrawable(R.styleable.SwipeButton_button_image_enabled);
float innerTextLeftPadding = typedArray.getDimension(
Expand Down
1 change: 1 addition & 0 deletions swipe-button/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<attr name="inner_text_top_padding" format="dimension"/>
<attr name="inner_text_bottom_padding" format="dimension"/>
<attr name="inner_text_background" format="reference"/>
<attr name="inner_text_wrap" format="boolean"/>
<attr name="button_image_width" format="dimension"/>
<attr name="button_image_height" format="dimension"/>
<attr name="button_trail_enabled" format="boolean"/>
Expand Down