Color in Button

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Color in Button

Postby kodex83 » Wed Dec 03, 2008 6:13 pm

How can I change the background color in a Button?

If I do this:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.                 <Button
  2.                 <span style="font-weight: bold">android:id="@+id/Schaltflaeche"</span>
  3.                 android:layout_width="wrap_content"
  4.                 android:layout_height="wrap_content"
  5.                 android:text="@string/login"
  6.                 android:layout_weight="1"
  7.                 <span style="font-weight: bold">android:background="@drawable/green"></span>
  8.                 </Button>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


The Emulator Shows as a Button a colored rectangle.

I use the 1.0 sdk.

Thank you.


P.S. Nice board here
Attachments
button.jpg
button.jpg (65.61 KiB) Viewed 242 times
kodex83
Freshman
Freshman
 
Posts: 9
Joined: Wed Dec 03, 2008 6:00 pm
Location: Germay

Top

Postby andmol » Thu Dec 04, 2008 11:15 am

Hi,

try this in your onCreate method:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Button button = (Button) findViewById(R.id.Schaltflaeche);
  3.  
  4. button.setBackgroundColor(Color.GREEN);
  5.  
  6.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


But it may look similar. I guess that android can only display the standard button as a nice looking button. Every time you change the color or use a different background, you get the a colored rectangle or the for example picture with the functionality of a button. If you want to have a nice looking button you have to draw your own.

Regards
andmol
Junior Developer
Junior Developer
 
Posts: 21
Joined: Tue Sep 30, 2008 5:34 pm

Postby kodex83 » Thu Dec 04, 2008 1:38 pm

Hi andmol,

thank you for your information!

Can I change the Button-Color by using a Theme? When the Button is pressed the Button shows a orange background color!

Have everyone information to create a new Theme? How can I change the Orange Color Theme to green? The Button has a orange highlight color when he is focused!

Regards kodex83
kodex83
Freshman
Freshman
 
Posts: 9
Joined: Wed Dec 03, 2008 6:00 pm
Location: Germay

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot] and 2 guests