Am using TextInputLayout. in that my cursor bottom bubble colour is in dark violet but I need it as white. I tried to change accent colour in theme but it donesn't work. And also am using Backpressed method for exit alert dialog. In that my positive and negative buttons also in violet colour but i need it as black. How can i achieve this?
Refer my snap.
Asked
Active
Viewed 291 times
0

Gokul
- 53
- 6
1 Answers
3
The cursor color is based on the primary color of the app.
You will need to create a style sheet and add it to your TextInputLayout view.
You can override the app's primary color in this way -
[a] If you want to change only cursor color-
Use -
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:theme="@style/ThemeOverlay.AppTheme.TextInputEditText.Outlined"
....>
with the style.xml file -
<style name="ThemeOverlay.AppTheme.TextInputEditText.Outlined" parent="">
<item name="colorControlActivated">@color/...</item>
[b] If you want to change the color of your EditText and Cursor both -
with this style.xml file -
<style name="ThemeOverlay.AppTheme.TextInputEditText.Outlined" parent="">
<item name="colorPrimary">@color/red</item>
</style>

paul035
- 327
- 2
- 8
-
It's not working. If I give theme as you given in Layout it's outline property is gone. – Gokul May 28 '21 at 02:51
-
I've added the screenshot do check out that. Also if not working can you please provide your layout file code. – paul035 May 28 '21 at 06:12
-
Thanks dude it's working great. In previous I made a mistake. How can i change the colour in my exit alert box? – Gokul May 28 '21 at 08:08
-
@Gokul You can update your style.xml file with this `` Check out the updated answer. – paul035 May 28 '21 at 08:35
-
I think you didn't get me. Cursor colour problem is solved. Refer second image. In that i need to change the Yes and No button's colour into black. – Gokul May 28 '21 at 08:44
-
I guess they depend on app's primaryColor try changing the primary color in your colors.xml file. – paul035 May 28 '21 at 08:46
-
No dude it's not working. I tried with Primary colour and PrimaryDark also. But got same result – Gokul May 28 '21 at 08:49
-
@Gokul Maybe this will help https://stackoverflow.com/a/33439849/9129342 – paul035 May 28 '21 at 08:52
-
1Found a solution of it. Button positive = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); positive.setTextColor(Color.BLACK); Button negative = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); negative.setTextColor(Color.BLACK); – Gokul May 28 '21 at 08:55