9

In API 21, we can use colorAccent to change the color of widgets like EditText, RadioButton etc. But it doesn't apply to the subclasses of those widgets. I've tried this but it's just like colorAccent, it applies only to original widgets.

Is there any solution to this? other than having to create a custom drawable then implements it as a style..

Community
  • 1
  • 1
Dark Leonhart
  • 1,494
  • 2
  • 13
  • 21
  • 2
    What do you mean by "subclass of EditText"? Are you saying that if you extend EditText then colorAccent doesn't apply? – Squonk Oct 31 '14 at 08:38
  • @Squonk yup..I made a custom EditText by extending the original EditText, but the colorAccent doesn't apply to my custom EditText. – Dark Leonhart Nov 03 '14 at 02:10

3 Answers3

12

For applying colorAccent just extend your custom EditText class from android.support.v7.widget.AppCompatEditText

AndrOvip
  • 385
  • 2
  • 12
11

Actually as of Android support 22.1 you should subclass AppCompatEditText.

Jessicardo
  • 826
  • 1
  • 8
  • 12
0

Since, you did not post any source code I'm guessing you're not inflating your view from an XML layout but rater calling new MyCustomEditText.

As the developers site stated: The material theme design can only be applied when loading views using a layout inflater.

This is because the new material design backport hooks into the layout inflation process.

Another reason could be do to the fact that the appcompat v7 library only loads the material design when it finds an EditText in the XML layout. And it does not recognize custom view components.

Google plans to release the Material backport widgets in to the public, they stated that these are currently still in development. You may want to override these special backport widgets it could possibly solve your problem. But since they are not public yet... you can't.

Rolf ツ
  • 8,611
  • 6
  • 47
  • 72