Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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"/>