I would like to add the new feature of textview which is autosizing the text. Which means that if you have a longer text in the textview, it will automatically resize or adjust the font to fit the textview.
I have included the appcompat-v7:26.0.0 in my build.gradle to have the feature available to low-end devices. But my problem is that I want to implement it in my custom Button. I know that the view button includes a textview in it.
How do I enable that feature in my custom button.
Here's my code for my custom button:
public class GotoButton extends Button {
    public static final String TAG = GotoButton.class.getSimpleName();
    public interface FloaterDragListener {
        void onFloaterDragStart(float screenX, float screenY);
        void onFloaterDragMove(float screenX, float screenY);
        void onFloaterDragComplete(float screenX, float screenY);
    }
    int[] screenLocation = {0, 0};
    boolean inFloaterDrag;
    boolean inLongClicked;
    int untouchableSideWidth = Integer.MIN_VALUE;
    FloaterDragListener floaterDragListener;
    public GotoButton(final Context context) {
        super(context);
    }
    public GotoButton(final Context context, final AttributeSet attrs) {
        super(context, attrs);
    }
    public GotoButton(final Context context, final AttributeSet attrs, final int defStyle) {
        super(context, attrs, defStyle);
    }
    @Override
    protected void onConfigurationChanged(final Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        untouchableSideWidth = Integer.MIN_VALUE;
    }
    @Override
    public boolean onTouchEvent(final MotionEvent event) {
        try {
            final int action = MotionEventCompat.getActionMasked(event);
            float x = event.getX();
            float y = event.getY();
            if (action == MotionEvent.ACTION_DOWN) {
                if (untouchableSideWidth == Integer.MIN_VALUE) {
                    untouchableSideWidth = getResources().getDimensionPixelSize(R.dimen.nav_prevnext_width) - getResources().getDimensionPixelSize(R.dimen.nav_goto_side_margin);
                }
                if (x >= 0 && x < untouchableSideWidth || x < getWidth() && x >= getWidth() - untouchableSideWidth) {
                    return false;
                }
            }
            getLocationOnScreen(screenLocation);
            float screenX = x + screenLocation[0];
            float screenY = y + screenLocation[1];
            if (action == MotionEvent.ACTION_DOWN) { // reset long-clicked status
                inLongClicked = false;
            }
            if (!inLongClicked) { // do not continue if finger is still down but it's because long click is in progress
                if (!inFloaterDrag) {
                    if (action == MotionEvent.ACTION_MOVE) {
                        if (x < 0 || y < 0 || x > getWidth() || y > getHeight()) {
                            cancelLongPress();
                            inFloaterDrag = true;
                            floaterDragListener.onFloaterDragStart(screenX, screenY);
                        }
                    }
                }
                // do not use "else"!
                if (inFloaterDrag) {
                    if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
                        inFloaterDrag = false;
                        floaterDragListener.onFloaterDragComplete(screenX, screenY);
                    } else {
                        floaterDragListener.onFloaterDragMove(screenX, screenY);
                    }
                }
            }
        }catch (Exception e){}
        return super.onTouchEvent(event);
    }
    public void setFloaterDragListener(final FloaterDragListener floaterDragListener) {
        this.floaterDragListener = floaterDragListener;
    }
    @Override
    public boolean performLongClick() {
        inLongClicked = true;
        return super.performLongClick();
    }
}
Thank you!
 
    