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 Implementing Designs for Android Customizing the Login Screen Customizing Buttons

Jaan Karu
Jaan Karu
4,675 Points

Custom button styling seems not working for me.

Hello, I have Android Studio 1.2.1.1. Trying to make this working although the lessons are for Eclipse. I created button_custon.xml in drawable folder, then I try as shown in the video to set background with it, but there is no such file in auto-suggest. Any ideas?

Andre Colares
Andre Colares
5,437 Points

Go to your res folder in windows explorer>create a txt document> change his name to custom_button.xml>inside the document paste it:

?xml version="1.0" encoding="utf-8"?> selector xmlns:android="http://schemas.android.com/apk/res/android"> item android:drawable="@color/pressed_purple_button" android:state_pressed="true" /> item android:drawable="@color/focused_purple_button" android:state_focused="true" /> item android:drawable="@color/light_purple_button" /> selector>

In your button declaration you will do like this:

<Button android:id="@+id/loginButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/EditTextLayout" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:text="@string/login_button_label" android:background="@drawable/button_custom" android:layout_marginLeft="@dimen/activity_horizontal_margin" android:layout_marginRight="@dimen/activity_horizontal_margin" android:textSize="13sp"/>