0

I am creating a dialog box using custom layout but in layout colorAccent is completely ignored and replaced by default teal color. I have changed my theme according to this answer. but still not working. I can add theme to at the time of creating dialog by its constructor but I want do it only by theme so it affects every dialog in my app.Any help appreciated thanks here is my theme.

<style name="AppTheme" parent="AppTheme.Base">
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    <item name="android:windowAllowReturnTransitionOverlap">true</item>
    <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
    <item name="android:alertDialogTheme">@style/Theme.Dialog</item>
</style>

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

<style name="Theme.Dialog" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

My dialog box look like this image Edittext cursor is ignoring my colorAccent.

Community
  • 1
  • 1
Abhishek Singh
  • 9,008
  • 5
  • 28
  • 53

1 Answers1

2

Here is a sample code

<style name="DialogStyle" parent="Theme.AppCompat.Light.Dialog">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">match_parent</item>
        <item name="colorAccent">@color/colorPrimaryDark</item>
</style>

Define style while initiating diaolog in activity.

Dialog dialog = new Dialog(mContext, R.style.DialogStyle);
tahsinRupam
  • 6,325
  • 1
  • 18
  • 34