It has to come from within. We can't control the feelings, thoughts and behaviors of others and it can be difficult to not let their choices affect our own, but it is an exercise in training the mind to focus. It is also beneficial to remove yourself from the presence of such people as often as possible. If you are glued to your TV and things like that - turn it off. I got rid of cable and stopped listening to "news" blather all day years ago and became an immediately more positive person because I was able to direct my energy towards what was going on in the actual world, around me. I also started doing more productive things with my time without the distractions of being a "news junkie". Now I keep up with current events by reading a bit of news, but then I carry on with my day and tune the media out.
There are many things you can do to reduce your exposure to negative influences. Train your mind to focus on possible solutions instead of the problems you encounter. Challenge yourself to try new things. When you are against something, try to be "pro" it's opposite and create that in your world. For example I am completely 100% anti-war. I focus on creating peace instead - by learning about the world and other cultures, by not fighting with my family and discussing our issues instead - things of this nature.
You can only control and change you - when you accept that, then you can start to work on creating a more positive place for yourself with some new habits.
Id also add that negativity happens. When we spend so much energy trying to avoid something, we feed it. If you are angry or sad, it's ok, don't push it away, instead try to understand what that emotion is telling you and work on the core issue. Often we get mad when we feel powerless or afraid. Address those feelings at the root, instead of just flying into a rage. Anger can have a good purpose and be turned towards positive action. "Negativity" has a positive purpose when we don't allow it to take over.