mahesmohan
mahesmohan

Reputation: 804

Appliying an accent color to an particular EditText while others are unaffected

I have a situtation where half of the activity has a background color similar to the ActionBar. Hence the EditText displayed in the region with the background should have a white accent color and the ones in the remaining region should have a the color of the ActionBar.

[Plan A]

I am using appcompat-v7 and managed to get the accent colors to all the EditText with <item name="colorAccent">@color/createTaskPrimaryActionBar</item> in the theme I have used for the activity. But this sets the color of all the edit texts to @color/createTaskPrimaryActionBar.

Is there a way to set individual colors to individual EditText ?

[Plan B]

My next best hope is setting up an ActionBar with custom layout with an EditText in it and I think that will complicate things. Also I'm not even sure if that is a good practice.

My hope is if I am using a darkaction bar shouldn't the accent color be light by default.

Have anybody tried Plan B, I dont want to invest more time in it if it's not worth it..

Upvotes: 1

Views: 874

Answers (1)

Pooja
Pooja

Reputation: 2467

For your Plan A.

It is possible set individual colors to individual EditText

youreditText.getBackground().setColorFilter(getResources().getColor(R.color.YourColor), PorterDuff.Mode.SRC_ATOP);

Upvotes: 2

Related Questions