1

I've encountered a strange problem. I am using a custom made button style but giving the textcolor as android:textcolor = "@android:color/black" in the activity_main.xml . I can see the black color text on the button in the preview pane but when I run the app on my mobile its showing white text instead of black. I tried changing the color to some other color too but nothing is working on my mobile.

It was working fine before I updated my android studio. I was working with the latest version in 1st week of february then I stopped developing. When I started 2 weeks back I updated studio and after I am facing this problem Here is the button code -

<Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Check-Up"
        android:paddingLeft="50dp"
        android:paddingRight="50dp"
        android:textSize="25sp"
        android:textColor="@android:color/black"
        android:background="@drawable/custom_button_style"
        android:layout_centerHorizontal="true"
        android:id="@+id/symptomsbutton"
        android:onClick="symptomsScreen"
        android:layout_below="@id/title"
        />

Edit:- Code for custom_button_style.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners
    android:radius="25dp"
    />
<gradient
    android:angle="45"
    android:centerX="35%"
    android:centerColor="#15E815"
    android:startColor="#68de2c"
    android:endColor="#52FF91"
    android:type="linear"
    />
<padding
    android:left="0dp"
    android:top="0dp"
    android:right="0dp"
    android:bottom="0dp"
    />
<size
    android:width="270dp"
    android:height="60dp"
    />
<stroke
    android:width="3dp"
    android:color="#388732"
    />

Code for styles.xml

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

Please help

Shantanu Singh
  • 345
  • 1
  • 5
  • 22

1 Answers1

3

Check your theme applied for your activity in manifest. And tally it with the theme applied in your XML design during development. If not same, then edit the theme applied to your activity.

Ankit Gupta
  • 674
  • 1
  • 6
  • 17
  • Theme in manifest is - android:theme="@style/Theme.AppCompat.NoActionBar" for this activity. There is no theme applied to this particular XML. Using default – Shantanu Singh Apr 05 '16 at 08:40