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

Why is my button becoming smaller when i click on it!!

Okay, So i am working thought the basic android development series but i have run into a snag. Whenever i click on the button it resizes to a very small button for some reason. Does anyone know whats causing this?

This sounds pretty awesome! (and probably really annoying)

Does it continually get smaller and smaller with every click? Or just smaller once and then stays that size?

My guess would be that your button xml attributes of: android:layout_width="match_parent" android:layout_height="wrap_content" are being changed. Basically if when you load the app the button has a large parent and then when you click the button, you change the parent (maybe because the parent is the textview above, I just finished the first android project). The second text is smaller than the first text and thus your button resizes based on the text size above it...

But that's just a guess! Please copy and paste your code in so we can better help :)

Does your button xml code look like this? (Note if you're not done then some attributes like background & textColor probably wont be the same but you can replacing your button xml with this, it shouldnt break anything AS LONG AS YOUR android:id IS THE SAME!) I'd check to make sure the layout_width and layout_height are the same as:

<Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Show Another Fun Fact"
        android:id="@+id/showFactButton"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:background="@android:color/white"
        android:textColor="#ff51b46d"
        android:clickable="true" /> 

1 Answer

Hehe. Could you post your code on here so that we can take a look?