Search This Blog

Mind freaker Stuff

Please Visit my new blog http://www.mindfreakerstuff.com for new articles related to web and mobile designing.

Thursday, June 7, 2012

How to create Styles for Android Button, UI (android Custom Button)

Android : How to create Style for Button which we can be use multiple time like CSS Classes in HTML  : Eclipse




1) Create Android Project  - Suppose we are creating a button style which has default blue color and on press orange color as shown in above image.




2) Create one android XML and select values as per shown in figure

Resource Type : Drawable
Root Element : Selector






 Add Folowing Code in bluebutton.XML



     
     
        
             
            
            
            
        
    
    
     
    
        
            
            
            
            
        
    





3)Create one more Android XML for styles  styles.xml  or you can use default string.xml

Resource Type : Values
Root Element : Resources



Add following Code in "Style.XML "




    




4) Add one Button in "main.xml" 






main.xml - 

  <Button
        android:id="@+id/button1"
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:text="My Button" 
        style="@style/btnBlue"/>


Thats it !! 


6 comments:

  1. startcolor = startColor

    ReplyDelete
  2. I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work. download App Cloner

    ReplyDelete
  3. I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. hoverwatch price

    ReplyDelete
  4. I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. HDfilme

    ReplyDelete