org.borderstone.tagtags.convenience.widgets.BButton.java Source code

Java tutorial

Introduction

Here is the source code for org.borderstone.tagtags.convenience.widgets.BButton.java

Source

/*   Copyright (c) The Krycklan Catchment Study, 2015
    
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
    
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
    
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.*/

package org.borderstone.tagtags.convenience.widgets;

import android.content.Context;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.view.Gravity;
import android.widget.Button;

import android.widget.TextView;
import org.borderstone.tagtags.R;
import org.borderstone.tagtags.convenience.Constants;
import org.w3c.dom.Text;

/**
 * Created by kim on 2015-02-11.
 */
public class BButton extends Button {
    public BButton(Context context) {
        super(context);

        super.setTextSize(Constants.fontSize);
        this.setTextColor(Color.BLACK);

        this.setBackgroundResource(R.drawable.custom_button);
        if (android.os.Build.VERSION.SDK_INT >= 21)
            this.setStateListAnimator(null);

        this.setTextColor(Color.WHITE);
        this.setAllCaps(false);
        this.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);

        this.setClickable(true);
    }

    public void setText(String text) {
        super.setText(" " + text);
    }

    public void setIcon(int icon) {
        this.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0);
    }
}