Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialog Button Theme #21

Open
ricknout opened this issue May 24, 2016 · 3 comments
Open

Dialog Button Theme #21

ricknout opened this issue May 24, 2016 · 3 comments

Comments

@ricknout
Copy link

Hi there,

It would be great if the SpectrumDialog adopted the theme of the current app / activity. I am specifically thinking of the dialog positive / negative buttons. My app uses a colorAccent of MD_Pink_500, and spectrum looks a little out of place with the default MD_TEAL_500 :-(

@nwalters512
Copy link
Member

I'm trying to figure out how to reference the attributes of the application that the library is included in (specifically colorAccent), but so far I can't find any way to do that. Do you know of any other open-source libraries that adopt the theme from the including application?

@ricknout
Copy link
Author

Hi @nwalters512 - for me, the only thing I believe needs colouring are the two dialog action buttons. This might be a way to do this:

Programmatically get the accent color in the following way:
http://stackoverflow.com/questions/27611173/how-to-get-accent-color-programmatically (replacing mContext with getApplication() / getActivity(), I would say).

Access the dialog buttons and set the text color, similar to this:
http://stackoverflow.com/questions/16469096/android-custom-dialogfragment-custom-positive-negative-button-design

No idea if this will work, but it seems like it might. I'll fork your project and try it out, will let you know how it goes.

@consp1racy
Copy link

The correct way to do this is to override alertDialogTheme attribute in your activity theme:

<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="colorAccent">#f00</item>
    <item name="alertDialogTheme">@style/AlertDialogTheme</item>
</style>

<style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="colorAccent">#f00</item>
</style>

alertDialogTheme is picked by any AlertDialog.Builder (one of which is used internally in SpectrumDialog).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants