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 Build a Simple Android App (retired 2014) Pretty Little Things Animating the Crystal Ball

answerLabel text has become invisible

I have added the animation to the ImageView and this works fine but I can no longer see any of the predictions.

Is it possible that the animation has been put on top of the text so it is obscuring it? I commented out the animateCrystalBall method call but this made no difference - the text was still invisible.

Any thoughts?

4 Answers

Hi Steve!

I think your imageView is overlaying (it is on top) of your TextView in your main layout. Try to change the order of the elements of the layout file in the "Outline" editor (activity_main.xml -> Graphical Layout -> Right side of the screen).

The vertical order of this list is representing your elements in the layout BOTTOM-UP (the first item in the list is behind the second one... and so on).

Hope this helps.

Martin

This is my activity_main.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitCenter"
        android:src="@drawable/ball01" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:weightSum="1" >

        <View
            android:id="@+id/view1"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="0.2" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.6"
            android:gravity="center_horizontal"
            android:shadowColor="@android:color/white"
            android:shadowRadius="10"
            android:textColor="@android:color/white"
            android:textSize="32sp" />

        <View
            android:id="@+id/view2"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="0.2" />
    </LinearLayout>

</RelativeLayout>
Masum Bergmann
PLUS
Masum Bergmann
Courses Plus Student 4,129 Points

Hi Steve, is your textView inside a linear layout? Check the visibility properties of your linLayout (if you have one) and of your textView. You can set a View's visibility property also programmatically, with something like: mTextContainer.setVisibility(View.VISIBLE); where mTextContainer has been initialized to the appropriate View.

Also make sure that your code generates an answer and that you call a method to display it. You can always add a second TextView to your layout and see if you can get the answer to appear in that TextView...

Hope that helps!

Thanks for the reply.

There's nothing in the XML that changes the Visibility property.

I'll try adding a new View tomorrow. It was all working before so I'm confused as to what I got wrong!

Steve.

Thanks Martin ....

My .xml didn't have

android:layout_weight = "0.6"

in it. I've corrected that.

I now have other problems caused by continuing with the course and adding sound etc. I now have other errors but I think my lack of text is probably fixed!

Thank you!

Steve.