Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Alex Johnson
Alex Johnson
6,067 Points

Button text disappearing in Android Studio

I'm following the "Build An Interactive Story" tutorial and am running into trouble with Android Studio. For some reason, the following XML is resulting in buttons with invisible text in Android Studio:

<Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAllCaps="@string/continueHomeToEarth"
        android:id="@+id/choiceButton1"
        android:layout_above="@+id/choiceButton2"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:background="@android:color/white"
        android:textColor="#ff3a8aec"/>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAllCaps="@string/stopAndInvestigate"
        android:id="@+id/choiceButton2"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:background="@android:color/white"
        android:textColor="#ff3a8aec"/>

Once I run the app on my phone, it shows up normally. Anyone have an idea what's going on? For the record, Android Studio is 0.8.2 and my phone is on Android 6.0.

Alex Johnson
Alex Johnson
6,067 Points

Turns out that android:textAllCaps takes a boolean, and not a string you want to appear in all caps. Changing it to this fixes the problem of the disappearing text.

<Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAllCaps="true"
        android:text="@string/stopAndInvestigate"
        android:id="@+id/choiceButton2"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:background="@android:color/white"
        android:textColor="#ff3a8aec"/>

I doubt anyone else will ever have this problem but I'll leave it here just in case.