Theme from Palette - android

I'm making an app that retrieve a lot of images from some server. I'm tinting each item in my List using Palette library. When a choose one I open another activity to show details of this item.
I want to build a theme based on the selected theme to apply in detail activity.
Is there a way to programmatically build a theme based on a Palette from a Bitmap?

If it is about the color of material design, there is a solution.
Remember: You cannot change the modify those colors at runtime but you can switch between themes at activity start.
When an user select a color, apply corresponding style and restart activity. Otherwise, change some other colors like Google keep
To set theme .
super.onCreate(savedInstanceState);
setTheme(...style.YourTheme);
To restart activity: Call the recreate() method of the activity.

Related

How to make circular reveal effect when theme changed? (Like in Telegram or VK)

I am using DayNight theme in my application. And I have a button that changes the theme. In VK and Telegram app there is a beautiful reveal animation that changes the theme without restarting activity or something like that.
I have tried to make that with reveal animation implementation in different ways, but it doesn't work or working bad in some cases with AppCompatDelegate.setDefaultNightMode(...). All examples with that reveal animation are for ActivityA -> ActivityB, but I just need to update theme without starting any activity.
And one more thing: AppCompatDelegate.setDefaultNightMode recreates my activity, so do I need a custom theme changing implementation?
And main question: how to create that animation with theme changing?
Examples:
Telegram (From Dark to Light)
Telegram (From Light to Dark)
VK (From Light to Dark)
VK (From Dark to Light)
since telegram is an open source app you can find the code -> line 3154: github.
it seems that it converts layout into bitmap and use it with an existing imageView to animate circular reveal

Custom Actionbar icon compatible with other themes the user may choose

When creating custom ActionBar icons what happens if the user changes their theme to something that makes your icon unreadable? Do they have this kind of power?
Example: So say I make an icon for my ActionBar in Holo Dark, so that the icon will be a lighter shade of white. What if the user changes their theme to Holo Light (or can they in my app?), forcing my icon to not be readable because it is also close to the same color as its background? I'm just concerned that if I create a custom app it will not look proper to only certain people.
I have been trying to find something about this but my searches and Google's Iconography pages didn't really give me a clear answer.
Android allows setting a themes to application/activity in AndroidManifest.xml, and you can change theme theme dynamically. If a user change their system themes, it don't affect you application. If you want to change your application/activity themes, you should call setTheme() before setContentView() in Activity.onCreate()

How do I get the default background color in ActionBarSherlock?

I am using the ActionBar from the ActionBarSherlock library. I am able to set the background color of my action bar using the ActionBar.setBackgroundDrawable(Color) method. After changing the background color, I later need to revert it back to the original/default ActionBar color.
How can I determine what the original/default color used for the ActionBar was?
Depends on the theme you are using. It should be
R.drawable.abs__ab_transparent_dark_holo for Theme.Sherlock
R.drawable.abs__ab_solid_light_holo for Theme.Sherlock.Light
R.drawable.abs__ab_solid_dark_holo for Theme.Sherlock.Light.DarkActionBar
Don't just Create a Model class that will remember what you are setting, and you be able to roll back when ever you wish.

Android, 3.0+ spinner dialog style

I am trying to change the drawable used as background in the spinner dialog. Prior 3.0 it works fine, I just change the AlertDialog style to use my images, but that does not work when the activity is inheriting from a Holo theme. I am trying to find which style I have to override but I simply cannot find which one is responsible for this.
I have tried inheriting from Theme.Holo.Dialog with no success.
Additionally, I am not able to completely override the selection selector drawable. Even when I supply my selector as background in the inherited #android:style/Widget.DropDownItem.Spinner, the device list selection is still visible under my selector.

Change colour of activated list item background on Honeycomb

For Honeycomb, I have set my listview items to use the ?android:attr/activatedBackgroundIndicator style so they remain highlighted when selected.
How do I change the colour of the highlight?
Define a custom theme with the item:
<item name="android:activatedBackgroundIndicator">#drawable/my_background</item>
Next, declare that drawable in a state list .xml file under res/drawable/my_background.xml as illustrated here: http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList Make sure that it has an item that responds to android:state_activated="true". This is your activated highlight.
The theme step is optional, (you could use the state list drawable directly if you choose,) but it gives an added layer of flexibility and since you've already defined your ListView items to use that theme attribute you can make this change in one place to affect any Activity that uses the custom theme.
If you need more info on themes look here: http://developer.android.com/guide/topics/ui/themes.html

Categories

Resources