0

I want to change the Text's color in a AndroidBootStrap Button.

I tried with android:textColor="@color/Pink" but the text still in black.

Peace of code including my bootstrap button in xml:

<com.beardedhen.androidbootstrap.BootstrapButton
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                bootstrapbutton:bb_size="xsmall"
                                android:text="Esporte"
                                android:textColor="@color/Pink"
                                bootstrapbutton:bb_icon_left="fa-check-circle-o"
                               bootstrapbutton:bb_text_alignment="left"
                                bootstrapbutton:bb_text_gravity="left"
                                />   

Any idea?

Alberto Crespo
  • 2,429
  • 5
  • 28
  • 51

3 Answers3

1

It can be done programmatically in the java file, but you would need to add an id to your button in the XML layout file first:

<com.beardedhen.androidbootstrap.BootstrapButton
    android:id="@+id/register_button"
    ... />

Then, in the Java file:

BootstrapButton b = (BootstrapButton) findViewById(R.id.register_button);
b.setTextColor(getResources().getColor(R.color.colorPrimaryDark));

Be aware that the method getColor(int) was deprecated in API 23, you can use it as

getColor(int, null)

if you will not support older API levels.

0

Did you try to do it in the create()??

When you create the bottom for first time you can change the properties and then put the textColor in pink :)

David_Garcia
  • 622
  • 7
  • 15
0

Bootstrap for android is a customised Library for having the similar look and feel of the default view of bootstrap for web. There is less scope for customisation. But if you really need to customise it then you can download the source of the Library project and add your customised properties in the BootstrapType constructor. Here is the source of the library of BootstrapButton. Just like the DEFAULT, PRIMARY you can add a CUSTOM property there you can add your color.

 private enum BootstrapType {
        DEFAULT("default", R.drawable.bbuton_default, R.drawable.bbuton_default_rounded, R.color.black),
        PRIMARY("primary", R.drawable.bbuton_primary, R.drawable.bbuton_primary_rounded, R.color.white),
        SUCCESS("success", R.drawable.bbuton_success, R.drawable.bbuton_success_rounded, R.color.white),
        INFO("info", R.drawable.bbuton_info, R.drawable.bbuton_info_rounded, R.color.white),
        WARNING("warning", R.drawable.bbuton_warning, R.drawable.bbuton_warning_rounded, R.color.white),
        DANGER("danger", R.drawable.bbuton_danger, R.drawable.bbuton_danger_rounded, R.color.white),
        INVERSE("inverse", R.drawable.bbuton_inverse, R.drawable.bbuton_inverse_rounded, R.color.white);

        private final String type;
        private final int normalBg;
        private final int roundedBg;
        private final int textColour;

        BootstrapType(String type, int normalBg, int roundedBg, int textColour) {
            this.type = type;
            this.normalBg = normalBg;
            this.roundedBg = roundedBg;
            this.textColour = textColour;
        }

        public static BootstrapType getBootstrapTypeFromString(String type) {
            for (BootstrapType value : BootstrapType.values()) {
                if (value.type.equals(type)) {
                    return value;
                }
            }
            return DEFAULT;
        }

        public int getTextColour() {
            return textColour;
        }

        public int getRoundedBg() {
            return roundedBg;
        }

        public int getNormalBg() {
            return normalBg;
        }
    }
Mohammad Arman
  • 7,020
  • 2
  • 36
  • 50
  • Do you know any tutorial about how to add a library project on Android Studio. All what I have found is not working for me. Thank you – Alberto Crespo Mar 20 '15 at 19:39
  • 1
    Yes, you can follow this link. The approved answer is perfectly explained. http://stackoverflow.com/questions/16588064/how-do-i-add-a-library-project-to-the-android-studio – Mohammad Arman Mar 20 '15 at 19:48