Android Material Design: Create theme changer - java

I was wondering if it's possible to implement a theme changer function in the Material Design, in a case whereby the user can access a settings page and then select say, a night theme (darker components) or a light theme (lighter components). I suppose it will require me to programmatically change the primary colors etc within an onItemClick? I just need to know if this is possible for the material design as I can't seem to find a way to do it online. Would also be grand if someone could tell me briefly the logic to implement such a function.

It is possible. You can check my app source code which has this functionality, however I suggest you to create custom views and whenever the user selects a color or change the theme you could post an event to the view to changes its color/tinting accordingly.
Github

Related

What's the most efficient way to change the overall theme of the app?

So I got an idea for an app that would change visual theme based on user's selection, something like how a Sub-Reddit would have the option for users to switch between themes. In this case, I would utilize at least 4 themes, each theme changing the color of certain views, such as the background, buttons, image, and etc. I would like to know the the best approach to this. Do I need to keep a list of views that would be affected or something?
I've tried keeping different button backgrounds with different color since setting background color programmatically would reset the background shape back to the default design, but I'm afraid that it will cause the app to be bloated with numerous files. I've tried using the color filter to change the views.
Color id still keeps the filter applied to it, causing it be unusable if user switch to different color, then back.
Hopefully, this question was directed at native development. If so, then you should take a look at the guidelines. You can create your themes in XML and reference them in your layout XML files.
Personally, I would store the theme as a SharePreference somewhere and then when laying out each Activity/Fragment, utilize the user's saved theme.

How to create some thing like gmail compose in android app

How I can create some thing like this? Has it any specific name or view? Like red cycle image in below link:
You can create that view using a ListView like its explained there: https://developer.android.com/training/material/lists-cards.html.
You can create the floating button using an oval shape with an image inside and set some elevation. Click here for more info How to create a floating action button (FAB) in android, using AppCompat v21?
Have a look at general Android Material Design Guidelines to get some additional insight for these kind of ui. https://developer.android.com/design/material/index.html
This can be useful for you. I made a "dummy" Gmail UI for show a material activity transition. https://github.com/coyarzun89/FabTransitionActivity

managing Persistent Visual Data (event driven buttons and ImageViews) throughout Activities of an application

I need some advice for those who are experienced making Android applications. What I would really like to have, for my application's appearance: at the top, a title-bar which is a ImageView (content is a png), and at the bottom a series of custom buttons which make up a tab-bar like thing. In between the title and the tab-bar is the Content, which may be anything... (most likely buttons)
I have been doing this by making a RelativeLayout which specifies LeftMargin and UpperMargin for x,y coordinates--
Currently all of my activities are inheriting a custom MyActivity class, which rebuilds the title and the tab-bar at the time of onCreate. This seems bad to me!
PART1)
---A solution to Persistent data
Since the "tab-bar" and the title are persistent no matter what screen you're on during this application's run-time, it makes the most sense to store them somewhere... How should I do this? Make a singleton object that the Activity's ask for?
I thought a little about the singleton object, and I'm not even sure what I would store, since the Views that are on displayed during Activity A have activity A as context, and not Activity B.
PART2)
---Animation Aesthetics
I would really like to have the "Content" (the view in the middle between title and tabbar) slide out to the left, and the new content slide in from the right. I.e, I'd like the tab-bar and the title to remain fixed while the "activities" change. is this at all possible? What should I do to achieve it?
one idea I had, was to make all of the program in one activity! I would create an animation for the Custom View in the middle, and I would override the "back" button to navigate correctly to the previous Custom View. Is that a horrible idea?
Anyone have any advice?
Read http://developer.android.com/design. Most of the design principles can be applied to apps that run on legacy releases; it's not just limited to Honeycomb and Ice Cream Sandwich. Do consider the Action Bar and Dashboard design patterns.
I don't really recommend using just one Activity -- generally, an Activity should be a separate, encapsulated, pretty well defined chunk of functionality that can execute independently of other Activities.
To avoid duplication of your UI, consider reusing XML layouts.
To avoid duplication of your logic, consider using Fragments. You should be able to mix and match them in your activities.
To achieve the animation you describe, consider implementing a ViewPager.
Using the ActionBarCompat sample app and Android Support Library, you can enjoy modern goodies like Action Bar, fragments, tabs, and horizontal sliding transitions on devices running Android all the way back to Donut (1.6).

What in Android would allow me to touch the edge of my screen while playing my game and slide over an Item screen?

Android has many useful tools when coming to views and screens and layouts.
Description: While playing my game (running around as a zombie bear eating humans) I would like to allow the player to access an items menu via sliding a menu from the right side/edge of the screen. Or at the least be able to access a game options menu (not game settings which would be the menu button).
What would be the best fit for description?
P.S How would I make a question like this less like a discussion and more like a straight forward programming question when I don't really know what's available to do this.
Also, if this is the case, please point me to another location to ask a question that may require a discussion.
Thank You!
Try looking at the SlidingDrawer class.
PS I personally don't see a problem with how you have worded your question if you are looking for ideas of views/widgets you need to perform a specific function/effect.
My first thought, and for a simple approach (this wouldn't be animated or dragged really), would be using a RelativeLayout where the portion representing the menu was initially set so that it's visibility were GONE, except for a small tab or arrow or something. When that tab/arrow is touched, the visibility of the View for the menu could be toggled to VISIBLE.
With visibility set to GONE, a view is not drawn or considered in any part of the layout pass when the screen is drawn.
You could populate a listview with some icons and when an particular icon is selected, then figure out which one was selected and then execute some function and hide the sidebar using an animation. I've never developed a game, so I'm not too sure how far it deviates from the standard, but I wish you the best of luck :) ! If you post the source let me know would love to test your game and see how you work with the source!

Animation support for Android SDK 1.5?

I'm trying to add some animations to my application. I've essentially got a few menu screens, that all eventually lead to the main application that is a surface view. I want to add some nice animations between screen like fading in and out between screens. What's the easiest way to do this that is supported by SDK1.5 and above (I want to target most users)?
I'm confused by what is and isn't supported in SDK1.5. My belief at the moment is that animations between different activities is not supported in 1.5 but animations in things like ViewFlipper are. It seems the easiest way is to set up a ViewFlipper, put each of my screens in that, set the animation settings and then use this to get nice transitions.
Also, is there a way to override the "no animations" setting that can be found in the phone's main settings screen under display? I'm making a game, so presentation is important, so I want to be sure that whatever I use will cause an animation regardless of this global setting.
My belief at the moment is that
animations between different
activities is not supported in 1.5 but
animations in things like ViewFlipper
are.
Correct.
It seems the easiest way is to set up
a ViewFlipper, put each of my screens
in that, set the animation settings
and then use this to get nice
transitions.
Either that or just directly apply AlphaAnimation and kin to your Views.
is there a way to override the "no
animations" setting that can be found
in the phone's main settings screen
under display?
No, but bear in mind that is only for inter-activity animations.
I'm making a game, so presentation is
important, so I want to be sure that
whatever I use will cause an animation
regardless of this global setting.
Then do not rely upon global settings. Which, in this case, means do not rely upon inter-activity animations.

Categories

Resources