-2

Hey guys i would like to ask how to change the color of the buttons in the activity_main.xml. The Buttons are from the palette of the eclipse and are not image views button but the simple ones. here is my code

activity_main.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/default1"
    android:orientation="vertical"
    tools:context="ca.my.demo.buttondemo.MainActivity" >

<Button

    android:id="@+id/btnDisplayMessage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:text="Kreatika"
    android:textColor="#ffffff"
    android:textStyle="bold|italic" />

  <Button

      android:id="@+id/btnDisplayMessage1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentRight="true"
      android:layout_alignParentTop="true"
      android:layout_marginTop="63dp"
      android:text="Galaktokomika"
      android:textColor="#ffffff"
      android:textStyle="bold|italic" />

    <Button

        android:id="@+id/btnDisplayMessage2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/btnDisplayMessage1"
        android:layout_marginTop="24dp"
        android:text="Allantika"
        android:textColor="#ffffff"
        android:textStyle="bold|italic" />

</RelativeLayout>
Pragnesh Ghoda シ
  • 8,318
  • 3
  • 25
  • 40
stapan
  • 13
  • 1
  • 2

1 Answers1

1

is that what you are looking for?

<Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Button"
        android:id="@+id/button"
        android:background="#ff2fa0ff" />
  • yes dadecki...this is exactly what i want.but how do i know the code for each color? – stapan Sep 16 '14 at 12:53
  • You can use this smal very useful program which is picking every color: just set mouse coursor on color and press Ctrc+X on keyboard :) link to download jcpicker: http://www.download3k.com/Install-Anny-Just-Color-Picker.html –  Sep 16 '14 at 12:56
  • And let me know if you work in Android Studio or Eclipse? –  Sep 16 '14 at 12:58
  • So you can just use jcpicker and get every color you want. OR use this: http://www.google.com/design/spec/style/color.html#color-ui-color-palette –  Sep 16 '14 at 13:18
  • thnaks a lot dadecki..it worked perfectly..;) – stapan Sep 16 '14 at 13:20
  • Happy to help you. Please don't forget to pick my answer;) –  Sep 16 '14 at 13:22